【问题标题】:is size related with screen density?尺寸与屏幕密度有关吗?
【发布时间】:2013-03-18 12:34:30
【问题描述】:

这是我第一次在平板电脑上观看我的应用程序,我一直使用手机。

这是一个nexus 7,而不是美丽。

我检查了添加 l、m、h 和 xh,它使用 h 密度,但按钮很小。

最后一个按钮的宽度与背景相同,但不固定屏幕。

    <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
android:background="@drawable/background"
>

    <ImageButton
        android:id="@+id/account_but"
        android:background="@null"
        android:contentDescription="@string/accountDesc"
        android:layout_marginTop="50dip"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/boton_usos" />

    <ImageButton
        android:id="@+id/alquilar_but"
        android:background="@null"
        android:contentDescription="@string/alquilarDesc"
        android:layout_marginTop="5dip"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/boton_alquilar" />


    <ImageButton
        android:id="@+id/paradas_but"
        android:background="@null"
        android:contentDescription="@string/paradasDesc"
        android:layout_marginTop="5dip"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/boton_paradas" />

    <ImageButton
        android:id="@+id/noticias_but"
        android:background="@null"
        android:contentDescription="@string/noticiasDesc"
        android:layout_marginTop="5dip"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/boton_noticias" />

    <ImageButton
        android:id="@+id/incidencia_but"
        android:background="@null"
        android:contentDescription="@string/incidenciaDesc"
        android:layout_marginTop="5dip"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/boton_incidencia" />

     <ImageButton
        android:id="@+id/informacion_but"
        android:background="@null"
        android:contentDescription="@string/infoDesc"
        android:layout_marginTop="5dip"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/boton_informacion" />


    <ImageButton
            android:id="@+id/banner_but"
            android:background="@null"
            android:contentDescription="@string/infoDesc"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="10dip"
            android:src="@drawable/banner" />  

    </LinearLayout>

如何让 hdpi 按钮变大??

【问题讨论】:

    标签: android android-layout hdpi


    【解决方案1】:

    最好包含整个布局。您的父布局之一似乎对宽度有限制。

    【讨论】:

    • 你在 @drawable 中使用 9patch 吗?如果您不告诉 android 如何拉伸图像,它将使用可绘制大小。
    • drawable 中的补丁是什么?
    • 谷歌它:onetwo。它有助于解释 android 如何针对不同的屏幕尺寸拉伸图像,也有助于不关心 Android 中屏幕尺寸的差异。
    • 我试过了,但据我了解,它会根据文本使按钮变大或变短,不是吗?我希望平板电脑更大。
    • 没有。下载此 hdpi icon 并将其设置为按钮的背景。然后检查其行为,将按钮的宽度设置为 fill_parent,例如 40dp。或者打开sdk/tools/draw9patch看看这张图是怎么拉伸的就明白了。
    猜你喜欢
    • 1970-01-01
    • 2019-03-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-04-05
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多