Android 将文本视图浮动到表格行的顶部
我的Android 将文本视图浮动到表格行的顶部,android,layout,tablerow,Android,Layout,Tablerow,我的表格行中有两个文本视图,但其中一个有一个大文本。我希望第一个文本视图浮动到表格行的顶部: <TableRow android:id="@+id/trLocation" android:layout_width="match_parent" android:layout_height="match_parent"> <TextView android:id="@+id/textV
表格行中有两个文本视图
,但其中一个有一个大文本。我希望第一个文本视图
浮动到表格行的顶部
:
<TableRow
android:id="@+id/trLocation"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/location"/>
<TextView android:layout_width="wrap_content"
android:textSize="50dp"
android:layout_height="wrap_content"
android:text="1234"
android:id="@+id/tvLocation"
android:layout_weight="1"
/>
</TableRow>
我试过使用layougravity
和gravity
,但它们都没有效果。试试这个
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="@+id/textView2"
android:layout_width="match_parent"
android:layout_height="50dp"
android:text="Small Text"
android:gravity="left|center"
android:textAppearance="?android:attr/textAppearanceSmall" />
<TableRow
android:id="@+id/trLocation"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/tvLocation"
android:layout_width="wrap_content"
android:layout_height="50dp"
android:layout_weight="1"
android:text="1234"
android:textSize="50dp" />
</TableRow>
</RelativeLayout>
这将引入一些冗余。当我更改textsize时,我还必须更改两个layout\u height
s。如果使用dim.xml设置数值(如textsize),则不需要在两个位置进行更改