Android 线性布局对齐问题
我需要在一行上有各种文本视图。然后我想以单线为中心。就好像它们是在单个文本视图中编写的一样。所以我使用线性布局。但我的问题是,当我将其倾斜到纵向时,文本垂直下降。我希望如果文本不适合屏幕,那么它们必须在倾斜时位于下一行的中心。我的问题和你的差不多。请任何人在这方面帮忙。My layout.xml如下所示Android 线性布局对齐问题,android,android-linearlayout,Android,Android Linearlayout,我需要在一行上有各种文本视图。然后我想以单线为中心。就好像它们是在单个文本视图中编写的一样。所以我使用线性布局。但我的问题是,当我将其倾斜到纵向时,文本垂直下降。我希望如果文本不适合屏幕,那么它们必须在倾斜时位于下一行的中心。我的问题和你的差不多。请任何人在这方面帮忙。My layout.xml如下所示 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
//some code here
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginBottom="30dp"
android:layout_gravity="center_horizontal" >
<TextView
android:id="@+id/tv_jobs_info_note"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#000000"
android:text="@string/jobs_info_note"
android:textSize="20dp"
android:paddingRight="5dp"
/>
<TextView
android:id="@+id/tv_my_job"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/my_job"
android:clickable="true"
android:textColor="#0000FF"
android:onClick="onWorkListClick"
android:textSize="20dp"
android:paddingRight="5dp"
/>
<TextView
android:id="@+id/tv_jobs_info_note_mid"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#000000"
android:text="@string/jobs_info_note_mid"
android:textSize="20dp"
android:paddingRight="5dp"
/>
<TextView
android:id="@+id/tv_team_job"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#0000FF"
android:clickable="true"
android:onClick="onWorkListClick"
android:text="@string/team_job"
android:textSize="20dp"
android:paddingRight="5dp"
/>
<TextView
android:id="@+id/tv_jobs_info_note_end"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/jobs_info_note_end"
android:textColor="#000000"
android:textSize="20dp"
android:paddingRight="5dp"
/>
</LinearLayout>
//Some more code here
<ImageView
android:id="@+id/img_current_job_map"
android:layout_gravity="center_horizontal|bottom"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/map" />
</LinearLayout>
//这里有一些代码
//这里有更多的代码
如果有其他方法,我们将不胜感激。也许您正在寻找类似的方法:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/relativeLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="35dp"
android:layout_marginTop="175dp"
android:text="TextView" />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/textView1"
android:layout_marginLeft="8dp"
android:layout_toRightOf="@+id/textView1"
android:text="TextView" />
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/textView2"
android:layout_alignBottom="@+id/textView2"
android:layout_marginLeft="8dp"
android:layout_toRightOf="@+id/textView2"
android:text="TextView" />
<TextView
android:id="@+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/textView3"
android:layout_alignBottom="@+id/textView3"
android:layout_marginLeft="8dp"
android:layout_toRightOf="@+id/textView3"
android:text="TextView" />
<TextView
android:id="@+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/textView1"
android:layout_marginTop="40dp"
android:layout_marginLeft="8dp"
android:text="TextView" />
<TextView
android:id="@+id/textView6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/textView5"
android:layout_alignBottom="@+id/textView5"
android:layout_marginLeft="8dp"
android:layout_toRightOf="@+id/textView5"
android:text="TextView" />
<TextView
android:id="@+id/textView7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/textView6"
android:layout_marginLeft="8dp"
android:layout_toRightOf="@+id/textView6"
android:text="TextView" />
<TextView
android:id="@+id/textView8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/textView7"
android:layout_marginLeft="8dp"
android:layout_toRightOf="@+id/textView7"
android:text="TextView" />
<TextView
android:id="@+id/textView9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/textView8"
android:layout_toRightOf="@+id/textView8"
android:layout_marginLeft="8dp"
android:text="TextView" />
</RelativeLayout>
你所要做的就是将
TextViews
像这样相对放置,我相信这应该是可行的。希望这有帮助。我尝试使用不同的字体大小。虽然这不是正确的方法,但仍然没有选择余地 我的建议是使用相对布局
,您可以使用align\u toLeftOf
等属性将您的文本视图
放置在彼此相邻的位置。尽可能避免嵌套布局。我只是在早些时候才使用过,但整条线都不在中间。你说中间是什么意思?中间是模拟器屏幕的中心。第一个单词出现在中间。其余部分是一致对齐的,当布局居中时,它会产生相同的结果。谢谢你这么辛苦,但这段代码正在剪切不在同一行中的文本。这意味着那些垂直下降的文本现在不会出现在屏幕上。