我已经包含与LinearLayout中的比重设定为 “中心”,显示在中心以下部件垂直的LinearLayout:调整的ImageView的ViewBounds当父布局内容溢出
- ImageView的
- TextInputLayout
- TextInputLayout
- 按钮
在小屏幕设备上时,这看起来很正常s,底部的按钮即将熄灭。当我为两个TextInputLayouts显示错误时,情况甚至更糟。
截图标准屏幕:
截图小屏幕:
问题:
我想要的是,在小屏幕上,ImageView应该调整自己以容纳所有视图,而在更大的屏幕上,ImageView应保持其最大可用大小,同时所有内容都显示在中心(如截图1所示)。
任何帮助将不胜感激! :)
源XML:
<?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"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="@dimen/input_view_margin"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:srcCompat="@drawable/ic_transaction_history_big" />
<TextView
style="@style/ReportHeading"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/txt_transaction_history" />
<android.support.v4.widget.Space
android:layout_width="wrap_content"
android:layout_height="40dp" />
<TextInputLayout
android:id="@+id/wrapperFromDate"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextInputEditText
android:id="@+id/edtFromDate"
style="@style/InputLayoutEditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:focusable="false"
android:hint="@string/hint_from_date" />
</TextInputLayout>
<TextInputLayout
android:id="@+id/wrapperToDate"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp">
<TextInputEditText
android:id="@+id/edtToDate"
style="@style/InputLayoutEditText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:focusable="false"
android:hint="@string/hint_to_date" />
</TextInputLayout>
<Button
android:id="@+id/btnSubmit"
style="@style/PrimaryButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="35dp"
android:text="@string/action_submit" />
</LinearLayout>
你是否用xml修复了你的视图的大小? 张贴您的xml? –
给视图赋予权重。然后使用scaleType调整图像的大小。 – Rachit