Hello,我希望你能帮我解决一个小问题。
我正在使用GRAVITY LEFT来使我的文本对齐到视图的左边,但我想让它在TextView中居中对齐,同时也要向左对齐。
以下是我目前的情况:
我想要的是:
我正在使用GRAVITY LEFT来使我的文本对齐到视图的左边,但我想让它在TextView中居中对齐,同时也要向左对齐。
以下是我目前的情况:
___________________________________
_ _ _ _ _ _| aaaaaaaaaaaaa |_ _ _ _ _ _
_ _ _ _ _ _| aaaaaaaa |_ _ _ _ _ _
_ _ _ _ _ _| aaaaaaaaaaaaaa |_ _ _ _ _ _
-----------------------------------
我想要的是:
___________________________________
_ _ _ _ _ _| aaaaaaaaaaa |_ _ _ _ _ _
_ _ _ _ _ _| aaaaaaaa |_ _ _ _ _ _
_ _ _ _ _ _| aaaaaaaaaaaaaa |_ _ _ _ _ _
-----------------------------------
在哪里:
_ _ _ _ = 文本视图之外
| = TextView 边缘
我尝试了 android:gravity = "left|center",但它不起作用,有什么想法吗?
谢谢。
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/image_button_wrapper"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_centerVertical="true">
<ImageView
android:id="@+id/left_button_image"
android:layout_centerVertical="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="@dimen/spacing_normal"/>
<Textview
android:id="@+id/textview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/left_button_image"
android:gravity = "center|left|left"
android:clickable="false"
android:focusable="false"
app:font_name="Roboto-Light.ttf"/>
textView
的父级是什么?如果您可以发布包含textview
和其父级的代码部分,将更容易解决您的问题。 - himanshu1496