【发布时间】:2018-08-08 17:25:00
【问题描述】:
我正在尝试设计一个 CardView 以在带有 GridLayout 的 RecyclerView 中实现它。我设计了 cardView,但是当我在具有不同屏幕尺寸的不同手机上证明我的设计时,设计不会自行缩放。我使用“dp”统一和“sp”统一,如“Android开发者”页面显示。我不知道我是否必须为每个屏幕尺寸或每个屏幕密度创建设计。
你能帮帮我吗?
代码:
<android.support.v7.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
app:cardCornerRadius="6dp"
app:cardElevation="4dp"
app:cardUseCompatPadding="true"
android:id="@+id/dlvsr_CardView">
<LinearLayout
android:layout_width="170dp"
android:layout_height="170dp"
android:orientation="vertical"
android:padding="4dp">
<ImageView
android:id="@+id/imageView2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:srcCompat="@drawable/ic_launcher_background" />
<TextView
android:id="@+id/textView2"
android:layout_width="match_parent"
android:layout_height="30dp"
android:ellipsize="end"
android:maxLines="1"
android:text="Text view tittle"
android:textSize="18sp"
android:textStyle="bold" />
<TextView
android:id="@+id/textView3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Text view subtittle" />
</LinearLayout>
以下是示例:
https://i.stack.imgur.com/nRpBY.png
https://i.stack.imgur.com/scL7K.png
【问题讨论】:
标签: android view size screen cardview