Android的tvdpi VS xhdpi屏幕问题 [英] Android tvdpi vs xhdpi screen issue

查看:361
本文介绍了Android的tvdpi VS xhdpi屏幕问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在开发直到最近在模拟器进行了测试的Nexus 7平板电脑(7.27'',800x1280:tvdpi)的应用程序。一切都很好,直到我决定测试应用程序在不同的模拟器,之一创建类似于三星Galaxy Note 2(5.6'',720x1280:xhdpi),它看起来并不那么好

I'm developing an app for a tablet which until recently was tested in an emulator for Nexus 7 (7.27'',800x1280:tvdpi). Everything was fine until I decided to test the app in a different emulator, one created similar to samsung galaxy note 2 (5.6'',720x1280:xhdpi) and it doesn't look so well.

例如,看看我用这个自定义警告对话框。

For example, take a look at this custom alert dialog I'm using.

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
          android:id="@+id/dialog_layout_root"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:padding="10dp"
          android:background="@color/light_gray">
         <Button
             android:id="@+id/facebook_login_button"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:layout_centerHorizontal="true"
             android:layout_marginTop="40dp"/>
         <TextView
             android:id="@+id/or_text"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:textIsSelectable="true"
             android:layout_centerHorizontal="true"
             android:layout_marginTop="20dp"
             android:textSize="20sp"
             android:textColor="@color/black"
             android:layout_below="@id/facebook_login_button"/>
         <TextView
             android:id="@+id/sign_in_text"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:textIsSelectable="true"
             android:layout_marginLeft="10dp"
             android:layout_marginTop="20dp"
             android:textSize="20sp"
             android:textColor="@color/gray"
             android:layout_below="@id/or_text"/>
         <EditText
             android:id="@+id/login_email"
             android:layout_width="320dp"
             android:layout_height="wrap_content"
             android:layout_marginLeft="10dp"
             android:layout_below="@id/sign_in_text"
             android:hint="@string/email_login"
             android:inputType="textEmailAddress"/>
         <EditText
             android:id="@+id/login_password"
             android:layout_width="320dp"
             android:layout_height="wrap_content"
             android:layout_marginLeft="10dp"
             android:layout_below="@id/login_email"
             android:hint="@string/pass_login"
             android:inputType="textPassword"/>
         <TextView
             android:id="@+id/case_sensitive_text"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:textIsSelectable="true"
             android:layout_marginLeft="10dp"
             android:layout_marginTop="20dp"
             android:textSize="18sp"
             android:textColor="@color/gray"
             android:layout_below="@id/login_password"/>
         <CheckBox
             android:id="@+id/remember_login"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:textColor="@color/black"
             android:layout_below="@id/case_sensitive_text"/>
         <Button
             android:id="@+id/sign_in_button"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:layout_below="@id/remember_login"
             android:layout_marginLeft="300dp"/>
         <TextView
             android:id="@+id/forget_password_text"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:textIsSelectable="true"
             android:layout_marginLeft="180dp"
             android:textSize="18sp"
             android:textColor="@color/black"
             android:layout_below="@id/sign_in_button"/>
         <View
            android:id="@+id/horizontal_line"
            android:layout_width="360dp"
            android:layout_marginTop="20dp"
            android:layout_height="1dp"
            android:background="@android:color/darker_gray"
            android:layout_below="@id/forget_password_text"/>
         <TextView
             android:id="@+id/new_app_text"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:textIsSelectable="true"
             android:textSize="18sp"
             android:textColor="@color/black"
             android:layout_below="@id/horizontal_line"/>
         <TextView
             android:id="@+id/create_account_text"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:textIsSelectable="true"
             android:textSize="18sp"
             android:textColor="@color/gray"
             android:layout_below="@id/new_app_text"/>
         <Button 
             android:id="@+id/create_account_button"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:layout_below="@id/create_account_text"
             android:layout_marginLeft="250dp"
             android:layout_marginTop="10dp"/>
         <TextView
             android:id="@+id/terms_conditions_text"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:textIsSelectable="true"
             android:textSize="12sp"
             android:textColor="@color/gray"
             android:layout_below="@id/create_account_button"/>
         <TextView
             android:id="@+id/vertical_rule"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:textIsSelectable="true"
             android:textSize="12sp"
             android:textColor="@color/gray"
             android:layout_below="@id/create_account_button"
             android:layout_toRightOf="@id/terms_conditions_text"/>
         <TextView
             android:id="@+id/privacy_policy_text"
             android:layout_width="wrap_content"
             android:layout_height="wrap_content"
             android:textIsSelectable="true"
             android:textSize="12sp"
             android:textColor="@color/gray"
             android:layout_below="@id/create_account_button"
             android:layout_toRightOf="@id/vertical_rule"/>             
</RelativeLayout>

正如你可以看到我使用的是相对布局和我到处使用DP和SP的字体大小。
如果您发现的警告对话框中甚至没有片段显示正确的背景。
你可以在这里看看: http://imageshack.us/g/692/tvdpi.jpg /

任何建议,为什么会出现这种情况?

Any suggestions why is this happening?

先谢谢了。

推荐答案

您可以创建tvdpi的图像,例如绘制-tvdpi和绘制,xhdpi如果你使用Eclipse已经创建了不同的文件夹,可绘制。
保持不同势图像accourding其密度。

You can create different Drawable folder for tvdpi images like drawable-tvdpi and drawable-xhdpi is already created if you use eclipse . Keep diffrent images accourding to their density.

请注意也创造Nexus7和三星Galaxy Note不同的布局文件夹中。

Note also create different layout folder for Nexus7 and samsung galaxy note .

例布局sw600dp于Nexus-7和布局sw360dpi了Galaxy Nexus的。

Example layout-sw600dp for nexus-7 and layout-sw360dpi for Galaxy nexus .

请您的布局文件这两个文件夹。

Keep your layout files in both folders.

这将工作:)

这篇关于Android的tvdpi VS xhdpi屏幕问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆