问题描述
在我ViewPager,有一个ImageButton的和TextView的持有由的LinearLayout,现在我改变他们一个TextView中与coupound绘制。
In my ViewPager, there was a ImageButton and TextView hold by LinearLayout, and now I change them to one TextView with coupound drawable.
<?xml version="1.0" encoding="utf-8"?>
<com.iclinux.android.custom_views.NoScrollTextView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:iclinux="http://schemas.android.com/apk/res-auto"
android:clipChildren="false"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true"
android:gravity="center"
android:paddingLeft="8dp"
android:paddingRight="8dp"
android:drawableTop="@drawable/icon_bg"
style="@style/EllipsizedSingleLineTextView"
android:textSize="@dimen/grid_item_title_size"
>
</com.iclinux.android.custom_views.NoScrollTextView>
我的问题是:触摸TextView的时候我无法让左或右,但如果去掉安卓重力=中心,它的工作原理......遗憾的是,文本不居中反正...
My question is: I can not flip left or right when touching the TextView, but if removed "android:gravity="center", it works... unfortunately, the text is not centered anyway...
public class NoScrollTextView extends TextView {
public NoScrollTextView(Context context) {
super(context);
}
public NoScrollTextView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public NoScrollTextView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
@Override
public boolean onTouchEvent(MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_MOVE)
return false;
return super.onTouchEvent(event);
}
}
这里发生了什么?非常感谢。
What happened here? thanks a lot.
推荐答案
机器人:单线=真正的力量机器人:scrollHorizontally 设置为true,并且根据我的测试只有你改变的安卓重力(即默认的重心似乎并没有给这个问题)
android:singleLine="true" forces android:scrollHorizontally to be set to true, and according to my tests only if you change android:gravity (i.e. default gravity seems not to give this problem).
我只需更换机器人解决了这个问题,一个TextView:单线=真正的是安卓MAXLINES =1
此更改后,我没有更多的问题与ViewPager。现在,它正在滚动的同时触摸元素是 Android的预期:重力=正确的
After this change, I had no more problems with the ViewPager. Now it is scrolling as expected while touching elements with android:gravity="right".
这篇关于不能滚动接触的TextView当ViewPager(与Android:重力=&QUOT;中心&QUOT;)在它的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!