我们正在开发一个Android应用程序 . 文本在5“设备上正常显示 . 但是在较小的设备(4”,3.5“)上被裁剪 . 为什么会发生?欢迎任何帮助 . 请看下面的截图 . ”信用“”借记“和”网“显示而不是下面的屏幕截图中的“信用卡”“借记卡”和“网上银行” .
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#ffffff" >
<include android:layout_width="match_parent"
android:layout_height="wrap_content"
layout="@layout/sdk_header"
/>
<RelativeLayout
android:id="@+id/topLogoLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginTop="0dp"
android:layout_marginRight="0dp"
android:layout_marginLeft="0dp"
android:layout_marginBottom="-11dp"
android:background="#e5e5e5"
android:paddingTop="10dp"
android:paddingBottom="20dp">
<TextView
android:id="@+id/youtxt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:gravity="right"
android:layout_marginTop="5dp"
android:text="You"
android:textSize="40sp"
android:textColor="#727272"
android:layout_marginLeft="10dp" />
<RelativeLayout
android:id="@+id/arrowLayout"
android:layout_toRightOf="@+id/youtxt"
android:layout_toLeftOf="@+id/companyLogo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:layout_centerHorizontal="true">
<TextView
android:id="@+id/txt_amount"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:text="Rs. 10"
android:textColor="#727272"
android:textSize="18sp" />
<ImageView
android:id="@+id/arrow"
android:layout_width="wrap_content"
android:layout_height="18dp"
android:src="@drawable/arrow"
android:layout_below="@+id/txt_amount" />
</RelativeLayout>
<ImageView
android:id="@+id/companyLogo"
android:layout_marginTop="5dp"
android:layout_marginRight="30dp"
android:layout_width="70dp"
android:layout_height="50dp"
android:layout_alignParentRight="true"
android:src="@drawable/wallet_logo"
android:scaleType="fitXY" />
</RelativeLayout>
<ImageView
android:id="@+id/orange_line"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:src="@drawable/orange_line"
/>
<com.viewpagerindicator.TabPageIndicator
android:layout_marginTop="0dp"
android:id="@+id/indicator" android:layout_height="wrap_content" android:layout_width="fill_parent" />
<android.support.v4.view.ViewPager android:id="@+id/pager" android:layout_width="wrap_content" android:layout_height="wrap_content" >
</android.support.v4.view.ViewPager>
</LinearLayout>
3 回答
这是一个复杂的主题,可以写一本书(也可能有) . 我将专注于我能看到的唯一问题:文本大小 .
看起来你的字体在小屏幕上太大了 . 虽然EditText也存在问题(它只是没有溢出),但这会影响看似于标签和按钮的内容 .
测量屏幕尺寸的有用方法是sw-dp(最短宽度设备无关像素) . 调整dp密度,使其在所有设备上约为160dpi . 对于宽度约为3英寸的5英寸平板电脑,应该是sw480dp设备 . 3“-3.5”屏幕的宽度约为2英寸,应该是sw320dp设备 .
要使此工作处于最简单的级别,您需要在
value-sw240dp
文件夹中放置一些文本大小设置,这些设置大约是默认sw480dp设备文本大小的3/4 .例如,这可能出现在该文件夹的
dimen
文件中 .我不能给你一本食谱,因为我没有关于你对其他款式或尺寸使用的信息 . 也许你可能有一个布局:
把它放在一个风格中会更好,但这不在这里 .
不同的设备可能具有不同的像素密度,屏幕尺寸,方向,分辨率和与密度无关的像素(dp) .
Solution -
为不同的屏幕尺寸定义不同的布局文件 .
确保您的布局可以适当调整大小以适应屏幕
根据屏幕配置提供适当的UI布局
确保正确的布局应用于正确的屏幕
默认情况下,Android会调整应用程序布局的大小以适应当前的设备屏幕 . 在大多数情况下,这很好 . 在其他情况下,您的UI可能看起来不太好,可能需要针对不同的屏幕尺寸进行调整 . 例如,在较大的屏幕上,您可能需要调整某些元素的位置和大小以利用额外的屏幕空间,或者在较小的屏幕上,您可能需要调整大小以使所有内容都适合屏幕 .
可用于提供特定于大小的资源的配置限定符是small,normal,large和xlarge . 例如,超大屏幕的布局应该在layout-xlarge /中 .
从Android 3.2(API级别13)开始,不推荐使用上述大小组,您应该使用swdp配置限定符来定义布局资源所需的最小可用宽度 . 例如,如果多窗格平板电脑布局需要至少600dp的屏幕宽度,则应将其放在layout-sw600dp /中 . 使用新技术声明布局资源将在有关为Android 3.2声明平板电脑布局的部分中进一步讨论 .
看 - Multiple Screen Support和Support Screen training docs .
你只需要创建与密度或屏幕大小相关的不同文件夹
选项1 .
有关更多说明,请查看此链接...
Multiple Screen Support
选项2 .
这将根据密度给出TextSize ..