小编Maa*_*yns的帖子

Android studio一直在用固定的dp值替换match_parent

Android studio(v 2.3.1)不断用match_parent固定的dp vanue 替换RelativeLayout.例如,当我输入match_parent作为宽度时,它将其替换为368dp.当我测试应用程序时,我发现RelativeLayout确实是错误的.

有谁知道如何解决这一问题?

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout 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:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="be.mawey.lamachat.LoginActivity">


    <RelativeLayout
        android:layout_width="match_parent" <!-- THIS IS BEING REPLACED WITH 368dp -->
        android:layout_height="match_parent" <!-- THIS IS BEING REPLACED WITH 495dp -->
        tools:layout_editor_absoluteX="8dp"
        tools:layout_editor_absoluteY="8dp">

        <Button
            android:id="@+id/buttonLogin"
            android:layout_width="match_parent"
            android:layout_height="50dp"
            android:layout_alignParentStart="true"
            android:layout_centerVertical="true"
            android:background="@color/colorPrimary"
            android:text="Login"
            android:textColor="@android:color/white"
            android:textSize="18sp"
            tools:layout_editor_absoluteX="8dp"
            tools:layout_editor_absoluteY="292dp" />

        <EditText
            android:id="@+id/editTextCode"
            android:layout_width="match_parent"
            android:layout_height="50dp"
            android:layout_above="@+id/buttonLogin"
            android:layout_alignParentStart="true"
            android:ems="10"
            android:hint="Secret code here"
            android:inputType="numberPassword"
            tools:layout_editor_absoluteX="8dp"
            tools:layout_editor_absoluteY="234dp" />

        <TextView
            android:id="@+id/textView3"
            android:layout_width="match_parent"
            android:layout_height="50dp"
            android:fontFamily="monospace"
            android:text="example"
            android:textAlignment="center"
            android:textColor="@color/colorPrimaryDark"
            android:textSize="36sp"
            android:textStyle="italic"
            tools:layout_editor_absoluteX="8dp"
            tools:layout_editor_absoluteY="16dp" />
    </RelativeLayout> …
Run Code Online (Sandbox Code Playgroud)

android android-studio

20
推荐指数
2
解决办法
1万
查看次数

按字母顺序对Arraylist进行排序

我正在做一个listViewarrayList.现在我希望listView按字母顺序排序..我已经在线搜索但是没有一个工作..我怎样才能实现它?

我的代码:

String[] Hospitals = getResources().getStringArray(R.array.Hospitals);
adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, Hospitals);

mListView.setAdapter(adapter);
Run Code Online (Sandbox Code Playgroud)

"Hospitals"是我的strings.xml文件中的列表.

android listview arraylist

3
推荐指数
1
解决办法
4906
查看次数

标签 统计

android ×2

android-studio ×1

arraylist ×1

listview ×1