导航抽屉列表视图项目大小始终更改

时间:2015-05-27 19:09:49

标签: android navigation-drawer

我在我的Android应用程序中使用导航抽屉。一切都运作良好,直到上周,当我发现列表视图文本变大,并在它恢复到正常大小后。我不明白问题出在哪里。这是我的代码:

 <android.support.v4.widget.DrawerLayout
 xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffffff" >

<FrameLayout
    android:id="@+id/frame_container"
    android:layout_width="match_parent"
    android:background="#ffffff"
    android:layout_height="match_parent" />

<!-- Listview to display slider menu -->


<LinearLayout
    android:id="@+id/drawerll"
    android:layout_width="wrap_content"
    android:layout_height="fill_parent"
    android:layout_gravity="start"
    android:background="#ffffff"
    android:orientation="vertical" >

    <LinearLayout
        android:id="@+id/drawerhead"
        android:layout_width="260dp"
        android:layout_height="wrap_content"
        android:layout_gravity="start"
        android:background="#00a9da"
        android:gravity="center_vertical"
        android:orientation="horizontal" >

        <LinearLayout
            android:layout_width="wrap_content"
            android:background="@drawable/profile_head"
            android:layout_height="wrap_content">
        <ImageView
            android:layout_width="70dp"
            android:layout_height="75dp"
            android:id="@+id/myimg"
        android:src="@drawable/profile" />
        </LinearLayout>

        <LinearLayout
            android:id="@+id/drawer"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="5dp"
            android:orientation="vertical" >

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textColor="#ffffff"
                android:id="@+id/usernameacount"
                android:text="anonymos nearby"
                android:textSize="7dp"
                />

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="5dp"
                android:textSize="5dp"
                android:id="@+id/usermailaccount"
                android:textColor="#ffffff"
               />
        </LinearLayout>
    </LinearLayout>
    <View
        android:layout_width="match_parent"
        android:layout_height="1dp"
        android:background="#ffffff" />

    <ListView
        android:id="@+id/list_slidermenu"
        android:layout_width="260dp"
        android:layout_height="match_parent"
       android:background="@color/bluedrawer"
        android:choiceMode="singleChoice"
        android:layout_gravity="start"
        android:divider="#66d2f1"
        android:textColor="#ffffff"
        android:dividerHeight="1dp"
        android:listSelector="@drawable/list_selector" />
</LinearLayout>
<!-- android:background="@color/list_background"!-->

抽屉列表项的xml

<?xml version="1.0" encoding="utf-8"?>
 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="48dp" 
android:background="@drawable/list_selector">

<ImageView
    android:id="@+id/icon"
    android:layout_width="25dp"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_marginLeft="12dp"
    android:layout_marginRight="12dp"
    android:contentDescription="@string/desc_list_item_icon"
    android:src="@drawable/home"
    android:layout_centerVertical="true" />

<TextView
    android:id="@+id/title"
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:layout_toRightOf="@id/icon"
    android:minHeight="?android:attr/listPreferredItemHeightSmall"
    android:textAppearance="?android:attr/textAppearanceListItemSmall"
    android:textColor="#ffffff"
    android:gravity="center_vertical"
    android:paddingRight="40dp"/>
      <!--        android:textSize="10dp"
        android:textSize="20px"
   !-->

<TextView android:id="@+id/counter"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@drawable/counter_bg"
    android:layout_alignParentRight="true"
    android:layout_centerVertical="true"
    android:textSize="20px"
    android:paddingRight="13px"
    android:visibility="gone"
    android:paddingLeft="13px"
    android:layout_marginRight="8dp"
    android:textColor="#fff"/>

1 个答案:

答案 0 :(得分:0)

避免将px / dp用于文本大小,您应该使用sp代替。我确定你在你的棉绒警告中看到了这个......

相关问题