Bir*_*irk 6 android textview android-layout android-cardview
在Android L中的CardView中使用时,有些视图没有包装它的内容.在早期版本的Android上测试相同的代码时,一切正常.这是我的布局:
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="@dimen/stock_row_height"
card_view:cardCornerRadius="@dimen/default_elevation"
card_view:cardElevation="@dimen/default_elevation"
card_view:cardUseCompatPadding="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/logo"
android:layout_width="@dimen/portals_logo_width"
android:layout_height="match_parent"
android:layout_centerVertical="true"
android:layout_margin="@dimen/portals_logo_margin"
android:adjustViewBounds="true"
android:src="@drawable/image_placeholder" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toEndOf="@+id/logo"
android:layout_toRightOf="@+id/logo"
android:background="@android:color/black"
android:orientation="vertical">
<TextView
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/holo_green_light"
android:text="portalAddress.com"
android:textColor="@android:color/black"
android:textSize="@dimen/portals_title_text_size" />
<TextView
android:id="@+id/description"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/holo_blue_light"
android:text="Sincronizado 04/12/14 às 14:25"
android:textColor="@color/medium_gray"
android:textSize="@dimen/portals_description_text_size" />
</LinearLayout>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
问题是高度的TextView"wrap_content"不起作用.这是Android Studio的预览可视化:
这与使用Android L的Samsung Galaxy S5上运行的布局相同:
如果我尝试为TextView(分别为25dp和18dp)设置固定高度,则父LinearLayout不会以与TextView相同的方式包装它的内容.
[TextView的固定高度] [3]
我错过了什么?不知道出了什么问题,因为这只发生在Android L.
编辑:我仍在寻找这个问题的解决方案.
尝试从 LinearLayout 中删除 android:layout_toEndOf="@+id/logo" ,因为它将此视图的起始边缘定位到徽标 ImageView 的末尾。
| 归档时间: |
|
| 查看次数: |
3219 次 |
| 最近记录: |