【发布时间】:2017-12-13 04:33:21
【问题描述】:
我正在为平板电脑和手机开发一个安卓应用。因此,为了实现这一点,我为手机(layout)创建了两个文件夹,为平板电脑布局创建了一个文件夹(layout-sw600dp)。
根据我之前的问题comment,我假设只有平板电脑会从layout-sw600dp 获取布局。但这似乎不起作用。
对于nexus 4, nexus 5, nexus 6, nexus 7 设备,它采用layout-sw600dp 布局。
我在这里缺少什么?如何计算手机/平板电脑大小以适合 DP 布局?
平板电脑和手机所需的设计:
另一个退休使用两个独立的布局:
手机设计:
标签设计:
针对下面answer 的回复帖子,我有一个这样的线性布局:
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/linearLayouttest">
<TextView
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_gravity="center_horizontal"
android:textColor="@color/black"
android:gravity="left"
android:text="LabelFirstName"
android:layout_marginTop="@dimen/_8sdp"
android:textSize="@dimen/_13sdp"
android:id="@+id/firstNameLabel"
android:layout_marginLeft="@dimen/_15sdp"
android:layout_marginRight="@dimen/_15sdp" />
<EditText
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:id="@+id/firstName"
android:layout_marginTop="@dimen/_3sdp"
android:background="@drawable/edt_bg"
android:textColor="@color/black"
android:layout_marginRight="@dimen/_15sdp"
android:layout_marginLeft="@dimen/_15sdp"
android:padding="@dimen/_5sdp"
android:textSize="@dimen/_14sdp"
android:textColorHint="@color/textColor" />
<TextView
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_gravity="center_horizontal"
android:textColor="@color/black"
android:gravity="left"
android:text="LabelLastName"
android:layout_marginTop="@dimen/_3sdp"
android:textSize="@dimen/_13sdp"
android:id="@+id/lastNameLabel"
android:layout_marginLeft="@dimen/_15sdp"
android:layout_marginRight="@dimen/_15sdp" />
<EditText
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:id="@+id/lastName"
android:layout_marginTop="@dimen/_3sdp"
android:background="@drawable/edt_bg"
android:textColor="@color/black"
android:layout_marginRight="@dimen/_15sdp"
android:layout_marginLeft="@dimen/_15sdp"
android:padding="@dimen/_5sdp"
android:textSize="@dimen/_14sdp"
android:textColorHint="@color/textColor" />
</LinearLayout>
当我改变方向时,文本视图不可见。有什么解决办法吗?
【问题讨论】:
-
您可以通过使用不同的尺寸文件来实现该目的,而不是创建多个布局。尝试this。
-
我试过了,但它不起作用,因为我有不同的电话和桌子设计。请检查我编辑的问题。
标签: android android-layout layout