【问题标题】:Expandable list view layout direction not working in tablet可扩展列表视图布局方向在平板电脑中不起作用
【发布时间】:2018-06-01 12:57:19
【问题描述】:

我正在三星 Galaxy Tab 3.7 英寸屏幕上运行应用程序。我为不同的屏幕尺寸做了不同的布局。问题是可展开列表视图的方向是从右到左,应该是从左到右。它适用于其他设备,但不适用于此设备。

这里是展开列表视图的代码:

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/drawer_layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    tools:openDrawer="start">

    <include
        layout="@layout/app_bar_welcome"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

    <android.support.design.widget.NavigationView
        android:id="@+id/nav_view"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:background="@color/dark_grey"
        android:fitsSystemWindows="true"
        app:headerLayout="@layout/nav_header_welcome"
        >
        <ExpandableListView
            android:id="@+id/navigationmenu"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_marginTop="160dp"
            android:background="@color/dark_grey"
            android:theme="@style/MenuItems"
            android:textSize="2dp"
            android:groupIndicator="@android:color/transparent"
            android:layoutDirection="rtl"/>
    </android.support.design.widget.NavigationView>
</android.support.v4.widget.DrawerLayout>

这是对齐错误的图像。文本应该在抽屉的左侧:

【问题讨论】:

    标签: android android-layout layout expandablelistview tablet


    【解决方案1】:

    删除layoutDirection 并添加alignParentLeft = true。

    <ExpandableListView
                android:id="@+id/navigationmenu"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_marginTop="160dp"
                android:background="@color/dark_grey"
                android:theme="@style/MenuItems"
                android:layout_alignParentLeft="true"
                android:groupIndicator="@android:color/transparent"
    
                />
    

    【讨论】:

    • @Pousti:带有悲伤表情的“它不起作用”不是一个有用的回应。你现在说有人应该不断猜测新的想法,直到它被修复。你最好解释一下如何它不起作用,你是否注意到任何有用的东西,或者将这个想法用于新的研究途径。
    • 分享你的代码?您分享的任何内容都无助于解决您的问题..
    • @halfer 如果可以的话,告诉我一些有用的东西。另外,是的,我尝试了不同的方向和布局对齐相关标签,但没有任何效果。代码似乎在其他设备上运行良好。即使在工作室设计面板中,布局对齐也会根据标签而变化,但它不会在设备上。
    • 我不明白你为什么添加了 android:layoutDirection="rtl" 标签。正如我在回答中所说,删除它并分享列表项的 xml 布局。
    • 它用于可扩展列表视图的方向。rtl 表示从右到左。方向的其他属性是 ltr(从左到右)。它们都改变了列表视图项目的方向工作室的设计面板和其他设备上,但不是在这个上
    【解决方案2】:

    遇到这个问题的人,问题出在设备上。由于它的分辨率,它被颠倒了。我在另一台具有类似型号的设备上运行它,它按预期工作。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-10-30
      • 1970-01-01
      • 1970-01-01
      • 2011-05-10
      • 2013-10-25
      • 1970-01-01
      • 2020-12-13
      相关资源
      最近更新 更多