Android 滚动不显示在文本视图的右侧
我有一个xml文本视图,其中定义了滚动条, 我还在TextView中设置了填充和背景,但问题是滚动条并没有显示在右侧,若paddingRight=20dp,那个么从右边缘向左滚动显示20dp 对于其他控件(如listview),它始终显示在右侧 需要在右侧设置填充和滚动显示的解决方案 编辑: xml文件:Android 滚动不显示在文本视图的右侧,android,textview,android-scrollview,Android,Textview,Android Scrollview,我有一个xml文本视图,其中定义了滚动条, 我还在TextView中设置了填充和背景,但问题是滚动条并没有显示在右侧,若paddingRight=20dp,那个么从右边缘向左滚动显示20dp 对于其他控件(如listview),它始终显示在右侧 需要在右侧设置填充和滚动显示的解决方案 编辑: xml文件: <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.a
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/main_bg"
android:orientation="vertical" >
<LinearLayout
android:id="@+id/dialog_lay"
android:layout_width="fill_parent"
android:layout_height="70dp"
android:layout_marginBottom="20dp"
android:layout_marginTop="22dp" >
<TextView
android:id="@+id/dialog"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:layout_weight="1"
android:background="@drawable/dialog"
android:gravity="center_vertical"
android:maxLines="100"
android:paddingBottom="5dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:paddingTop="5dp"
android:scrollbars="vertical"
android:text="@string/dialog_text"
android:textColor="@color/text_color"
android:textSize="15sp" />
</LinearLayout>
</RelativeLayout>
您是否尝试过设置android:paddingRight=2sp?为什么不在线性布局中添加滚动视图
<LinearLayout android:id="@+id/LinearLayout01"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<ScrollView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1">
<TextView android:id="@+id/TextView01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
</TextView>
</ScrollView>
</LinearLayout>
删除下面的行
android:paddingRight="10dp"
或者设置为android:paddingRight=“0dp”
然后滚动条将向右对齐
填充是边框内的空间,在边框和实际视图内容之间。因此,如果您在textview中赋予paddingRight,则很明显,它也将为作为textbox一部分的滚动条赋予填充。您可以发布XML吗?滚动视图在哪里。你添加了吗?但我希望文本填充从右边开始,滚动条也应该显示在右边,还有其他解决方案吗?没有,我不这么认为,因为滚动条本身就是文本框的一部分。这并不能回答这个问题。要评论或要求作者澄清,请在他们的帖子下方留下评论-你可以随时对自己的帖子发表评论,一旦你有足够的评论,你就可以发表评论。请记住这一点,以备将来参考@TheHippo。Thanx表示平视。设置填充将移动文本视图中的滚动视图,因此将
paddingRight
设置为较小的值将移动滚动条。