Android 线性布局中的自动缩放元素
我有一个简单的fragmet,我希望它看起来像下图: 我的片段代码:Android 线性布局中的自动缩放元素,android,Android,我有一个简单的fragmet,我希望它看起来像下图: 我的片段代码: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.androi
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
app:layout_constraintBottom_toBottomOf="parent"
tools:context=".SignFragment">
<android.support.constraint.ConstraintLayout
android:id="@+id/wrapper"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="@dimen/wrapper_padding">
<ImageView
android:id="@+id/imageOne"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
app:srcCompat="@drawable/example" />
</android.support.constraint.ConstraintLayout>
<android.support.constraint.ConstraintLayout
android:id="@+id/info"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="15dp">
<TextView
android:id="@+id/infoMessage"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="@string/info_message_example"
android:textColor="@color/colorInfoMessage"
android:textSize="25sp" />
</android.support.constraint.ConstraintLayout>
</LinearLayout>
.
在景观变化上,文字是隐藏的
我尝试在
或其他元素上添加一些属性。
当我在第一次发布时添加了android:layout_weight=“1”
横向变化是正确的,但纵向方向被破坏
如何更改xml文件以获得正确的结果?要为纵向和横向模式创建单独的片段设计,请创建两个不同的xml
文件,一个用于纵向模式的设计,另一个用于横向模式。将layout port
和layout land
文件夹放入res文件夹中
例如:
res/layout-port [Portrait Mode; default]
main.xml
res/layout-land [Landscape Mode]
main1.xml
参考文件: