1

项目有 4 个可绘制和布局文件夹(xh、h、m、l)。这是清单的一部分:

<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="15" />
<supports-screens
    android:smallScreens="true"
    android:normalScreens="true"
    android:largeScreens="true"
    android:xlargeScreens="true"
    android:anyDensity="true" />

这是xhdpi的整个主要xml代码:

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

<RelativeLayout
    android:id="@+id/bg_header"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="top"
    android:background="@drawable/bg_header"
    android:padding="0dip">
    <ImageView
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:src="@drawable/text_header" />
</RelativeLayout>

<ListView
    android:id = "@android:id/list"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:divider="@null"
    android:dividerHeight="2.5dp"
    android:layout_marginTop="10dp"
    android:layout_marginBottom="10dp"
    android:cacheColorHint="@android:color/transparent"
    android:listSelector="@android:color/transparent"
    />
</LinearLayout>

这是 xhdpi 的行 xml:

<?xml version="1.0" encoding="UTF-8"?>
<LinearLayout
xmlns:android = "http://schemas.android.com/apk/res/android"
xmlns:foo="http://schemas.android.com/apk/res/test"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingRight="20dp"
android:paddingLeft="20dp">

<LinearLayout
    android:orientation="horizontal"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:background="@drawable/menu_selector">

<test.TextViewPlus
    android:id="@+id/menutext"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:textColor="#3D1E00"
    android:textSize="@dimen/TitleNormalXH"
    foo:customFont="Mj_Shablon.ttf"
   android:gravity="right|center_vertical"/>
</LinearLayout>
</LinearLayout>

这是银河笔记模拟器设置: dpi:285 。安卓版本:google api level 10 (2.3.3)

这是输出:

在此处输入图像描述

第二个问题:put android:background="@drawable/menu_selector" for row 的布局和 listview 的布局有什么不同?

4

2 回答 2

1

我想这会有所帮助:在你的适配器中,在 getView(...) 方法中,在你给你的行充气之后,使用这个:

row.setMinimumHeight(height);

方法的参数在 pixle 中,您应该选择特定的 dp 高度,然后将其转换为 px。

于 2012-08-18T09:32:59.590 回答
0

主要的xml代码:

<?xml version="1.0" encoding="utf-8"?>
<merge xmlns:android="http://schemas.android.com/apk/res/android">
<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical">
    <RelativeLayout
        android:id="@+id/bg_header"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:background="@drawable/bg_header">
        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/text_header" />
    </RelativeLayout>
    <ListView
        android:id = "@+id/mainlist"
        style="@style/ListView"
        android:dividerHeight="2.5dp"
        android:layout_marginTop="10dp"
        android:layout_marginBottom="10dp"/>
</LinearLayout>
</merge>

行xml代码:

<?xml version="1.0" encoding="UTF-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:dr="http://schemas.android.com/apk/res/pak"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingRight="20dp"
android:paddingLeft="20dp">
<RelativeLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:background="@drawable/menu_selector"
    android:gravity="center">

    <pak.TextViewPlus
        android:id="@+id/menutext"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="right"
        android:textSize="@dimen/TitleNormalM"
        android:gravity="right"
        dr:customFont="Mj_Shablon.ttf"
        android:padding="0dp"/>

</RelativeLayout>
</RelativeLayout>

和九个补丁图像必须是这样的:http://i.stack.imgur.com/PE9ly.png

于 2012-08-26T11:57:21.380 回答