在Android中支持不同的屏幕尺寸(密度)时,通常关注的是为每个可能的屏幕创建不同的布局.IE
我为xhdpi屏幕设计了一个布局作为参考,并在dimens.xml中定义了它的尺寸.现在我想支持每个可能的屏幕尺寸.我怎样才能做到这一点?
据我所知,我可以使用此工具找出适合其他屏幕尺寸的dimens.xml并将其添加到我的项目中.这是在我的情况下这样做的正确方法吗?
另一个问题,我是否只需要为上面的屏幕尺寸创建dimens.xml?如果是,那么是什么w820dp?
谢谢你的帮助.我只需要支持手机(不是平板电脑或其他设备).
android android-layout android-screen-support android-activity
我有一个RecyclerView包含CardViews TextView和a ImageView,以及其他一些布局的s .
问题是,在某些屏幕分辨率TextView下,它会被切断或推到下一行,这是我不想要的.
在其他决议中,TextView有足够的空间.
如何组织布局,以便有足够的空间TextView,并相应ImageView地调整大小?
这是我的RecyclerView项目的xml :
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:cardview="http://schemas.android.com/apk/res-auto"
android:id="@+id/zmanCard"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_gravity="center_horizontal"
android:gravity="center_horizontal"
cardview:cardUseCompatPadding="false"
cardview:cardPreventCornerOverlap="false"
cardview:cardCornerRadius="4dp"
cardview:cardElevation="2dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/colorPrimary"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="20dp"
android:layout_gravity="top"
android:gravity="center"
android:orientation="vertical"
android:background="?attr/colorPrimaryDark">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/zmanCardTitle"
android:textColor="#ffffff"
android:gravity="center"
android:textSize="13sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:layout_width="24dp"
android:layout_height="wrap_content"
android:layout_marginTop="2dp"
android:layout_marginLeft="2dp"
android:layout_marginRight="4dp"
android:alpha="0.8"
android:id="@+id/zmanCardImage" />
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="7dp"
android:layout_marginLeft="0dp"
android:layout_marginRight="4dp">
<TextView …Run Code Online (Sandbox Code Playgroud)