目前我正在开发一些包含list
的android
应用程序。
我在移动(手机)设备中制作了一个。
我想让它在平板电脑(7“-10”)显示屏上响应
。因此标题
和列
看起来与移动显示中的相同。
这是 5 英寸和 7 英寸显示屏之间的差异:
这是我当前的 xml 代码
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="match_parent"
android:tag="reqtag"
>
<TableLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TableRow
android:layout_width="match_parent"
android:layout_height="match_parent"
android:showDividers="beginning|end"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Date"
android:id="@+id/tvClaimDateReimbursementRequest"
android:layout_marginRight="50dp"
android:textSize="12dp"
android:width="100dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Type"
android:textSize="12dp"
android:layout_marginLeft="50dp"
android:layout_marginRight="50dp"
android:id="@+id/tvTypeRequestReimbursement"
android:width="80dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Amount"
android:textSize="10dp"
android:layout_marginLeft="50dp"
android:layout_marginRight="50dp"
android:width="100dp"
android:id="@+id/tvAmountReimbursementRequest" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Status"
android:textSize="12dp"
android:layout_marginLeft="50dp"
android:layout_marginRight="50dp"
android:id="@+id/tvStatusReimbursementRequest" />
</TableRow>
</TableLayout>
我在这里看过文档 https://developer.android.com/guide/practices/screens_support.html
但是我还是没明白 有没有最佳实践来做这样的事情?
谢谢
最佳答案
你可以尝试设置
android:layout_width="0dp"
android:layout_weight="1"
对于每个标题TextView
,因为TableRow
是一个LinearLayout
。
但我相信 TableView
不是最好的方法。如果您描述您想要实现什么,我们可以找到更好的方法。
关于java - 如何使 TableLayout 响应式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40481551/