我想要一个视图,如果屏幕尺寸较小,则可以具有最小高度或wrap_content;如果屏幕尺寸较大,则占据其余空间。该视图是其父视图的中间子视图。
目前,我正在使用 LinearLayout 的权重。它在大屏幕上工作正常,但在小屏幕上它不显示视图。
<?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:id="@+id/main_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/speaker_detail_background"
android:clickable="true"
android:paddingLeft="@dimen/padding_7dp"
android:paddingRight="@dimen/padding_7dp"
android:orientation="vertical"
>
<ImageView
android:id="@+id/down_arrow_image_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:padding="@dimen/padding_15dp"
android:src="@drawable/down_arrow_icon" />
<RelativeLayout
android:id="@+id/lytSpeakerDetails"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/down_arrow_image_view"
android:minHeight="200dp"
android:layout_weight="1"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true">
<RelativeLayout
android:id="@+id/title_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/ThemeOverlay.AppCompat.Dark"
android:visibility="visible"
>
<com.harman.jblconnectplus.ui.customviews.CustomFontTextView
android:id="@+id/speaker_name_title_textview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:background="@android:color/transparent"
android:drawableLeft="@drawable/edit_name"
android:drawablePadding="@dimen/padding_5dp"
android:ellipsize="end"
android:maxLength="16"
android:text="@string/speaker_name"
android:textColor="@android:color/white"
android:textSize="@dimen/textSize_18sp"
app:font="@string/font_name_opensans_semi"
/>
<com.harman.jblconnectplus.ui.customviews.CustomFontTextView
android:id="@+id/setting_text_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/speaker_name_title_textview"
android:layout_centerHorizontal="true"
android:text="@string/setting"
android:visibility="invisible"
android:textColor="@color/white"
android:textSize="14sp"
app:font="@string/font_name_opensans_semi"
/>
</RelativeLayout>
<LinearLayout
android:id="@+id/lytSeekBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_below="@id/title_bar"
android:layout_marginLeft="@dimen/brightness_margin"
android:layout_marginRight="@dimen/brightness_margin"
android:visibility="visible">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/darker"
android:layout_gravity="center_vertical"
/>
<SeekBar
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:id="@+id/seekBar"
android:thumb="@drawable/knob"
android:progressDrawable="@drawable/seekbar_progressbar"
android:indeterminate="false"
android:splitTrack="false"
android:maxHeight="3dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:progress="0"
android:secondaryProgress="0"
android:max="255"
/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/brighter"
android:layout_gravity="center_vertical"/>
</LinearLayout>
</RelativeLayout>
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:id="@+id/bottom_details_layout"
android:layout_height="wrap_content"
android:background="@drawable/round_border_white_bg"
android:orientation="vertical"
android:layout_marginTop="@dimen/margin_20dp"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="@dimen/padding_5dp"
android:gravity="bottom">
<include layout="@layout/speaker_detail_firmware_layout" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="0.5dp"
android:background="@color/divider_view" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<include layout="@layout/speaker_detail_voice_layout" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
请建议。
Your View
正在受到约束。minHeight
如果View
受到限制。请参阅文档 https://developer.android.com/reference/android/view/View.html#attr_android:minHeight.
机器人:最小高度
定义视图的最小高度。不保证视图能够达到此最小高度(例如,如果其父布局用较小的可用高度限制它)。
Maybe a ScrollView
是您可以使用的东西,因为它为您提供了几乎无限的空间。问题是,当空间成为问题并且一切都无法容纳时,您希望发生什么。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)