视图基本上就像这样设置
LinearLayout -orientation horizontal - Height (wrap)
LinearLayout -orientation vertical - Height (wrap) - weight .65
TextView
RecyclerView
LinearLayout - orientation vertical - Height (matchparent) - weight .35
TextView
TextView
TextView
在大多数情况下,第一个LinearLayout(左边的)会确定高度的大小,因为RecyclerView通常会有多个条目。但是在图像的情况下,第一行这个逻辑不起作用。如果我将LinearLayout设置为右边的换行,那么当左边的那个更大时,灰色背景周围会有白色。实现第二个布局的最佳方法是始终与其父级相同的高度,如果父级太小,则父级调整为它。
这里是请求的完整xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_marginBottom="4dp"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<FrameLayout
android:background="?attr/selectableItemBackground"
android:layout_width="match_parent" android:layout_height="wrap_content">
<ProgressBar android:id="@+id/progressBar" android:layout_width="wrap_content" android:layout_height="match_parent"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:baselineAligned="false"
android:orientation="horizontal">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight=".65"
android:orientation="vertical"
android:padding="@dimen/activity_horizontal_margin">
<TextView
android:id="@+id/tv_organization"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
android:textStyle="bold"
tools:text="Duke Hospital"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/availablehours"
android:textAppearance="@android:style/TextAppearance.Small"/>
<TextView
android:id="@+id/rv_available_hours"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clickable="false"
android:focusable="false"
android:padding="0dp"
android:paddingBottom="4dp"
android:textAppearance="@android:style/TextAppearance.Small"/>
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight=".35"
android:background="@color/offWhite"
android:gravity="center"
android:orientation="vertical"
android:paddingEnd="@dimen/activity_horizontal_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingStart="@dimen/activity_horizontal_margin">
<TextView
android:id="@+id/tv_notavailable"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:textAppearance="@style/TextAppearance.AppCompat.Subhead"
android:textColor="@color/darkerGreyColor"
android:visibility="gone"/>
<TextView
android:id="@+id/tv_duration"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:textAppearance="@style/TextAppearance.AppCompat.Display1"
android:textStyle="bold"
tools:text="30"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:textAllCaps="true"
android:layout_gravity="center_horizontal"
android:text="@string/abbrev_min"/>
<TextView
android:id="@+id/tv_labelDuration"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="@string/estimatedwaittime"
android:textAppearance="@style/TextAppearance.AppCompat.Caption"/>
</LinearLayout>
</LinearLayout>
</FrameLayout>
</android.support.v7.widget.CardView>
答案 0 :(得分:0)
您可以设置
的minHeightLinearLayout -orientation vertical - Height (wrap) - weight .65
这样右侧文字就不会被剪裁