如果屏幕尺寸很小,並且屏幕尺寸較大,則需要可以具有最小高度的視圖或wrap_content,然後佔據該空間的其餘部分。這種觀點是其父母的中間孩子。minHeight無法在Linearlayout中使用weight =「1」
目前,我正在使用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>
請建議。
能你分享你的佈局代碼? –
發佈您的xml文件和屏幕截圖。 –
到目前爲止您嘗試過什麼? –