这个XML代码有什么问题? - Android Studio
问题描述:
我创建了一个包含200个声音和一个BottomNavigationBar的音板。 像华为P8精简版和三星galaxy一些设备S7它看起来像这样: https://gyazo.com/2a08bcd731fb1cfeb07e72f75bc05e7e这个XML代码有什么问题? - Android Studio
而且我的氮氧化物播放器和蓝叠它看起来像这样: https://gyazo.com/e26327d7ba0ed366f15c61bd3130ae39
这里是唯一的XML代码2个colums 3行只是为了保持它在夏日(Normaly有100行)
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/res-auto"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/background2"
android:orientation="vertical"
android:layout_marginTop="50dp">
<ImageView
android:id="@+id/imageView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
/>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<GridLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<Button
android:id="@+id/button1"
android:layout_weight = "1"
android:layout_height="100dp"
android:layout_column="0"
android:layout_columnWeight="1"
android:layout_rowWeight="1"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:background="@drawable/mybutton"
android:onClick="Button1"
android:padding="3dp"
android:text="Button1"
android:textColor="#ffffff"
android:textSize="20dp" />
<Button
android:id="@+id/Button2"
android:layout_weight = "1"
android:layout_height="100dp"
android:layout_column="0"
android:layout_columnWeight="1"
android:layout_rowWeight="1"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:background="@drawable/mybutton"
android:onClick="Button2"
android:padding="5dp"
android:text="Button2"
android:textColor="#ffffff"
android:textSize="20dp" />
<Button
android:id="@+id/Button3"
android:layout_weight = "1"
android:layout_height="100dp"
android:layout_column="0"
android:layout_column="1"
android:layout_row="1"
android:layout_rowWeight="1"
android:layout_columnWeight="1"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:background="@drawable/mybutton"
android:onClick="Button3"
android:padding="5dp"
android:text="Button3"
android:textColor="#ffffff"
android:textSize="20dp" />
<Button
android:id="@+id/Button4"
android:layout_weight = "1"
android:layout_height="100dp"
android:layout_column="0"
android:layout_column="0"
android:layout_row="1"
android:layout_rowWeight="1"
android:layout_columnWeight="1"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:background="@drawable/mybutton"
android:onClick="Button3"
android:padding="5dp"
android:text="Button4"
android:textColor="#ffffff"
android:textSize="20dp" />
<Button
android:id="@+id/Button5"
android:layout_weight = "1"
android:layout_height="100dp"
android:layout_column="0"
android:layout_column="0"
android:layout_row="2"
android:layout_rowWeight="1"
android:layout_columnWeight="1"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:background="@drawable/mybutton"
android:onClick="Button5"
android:padding="5dp"
android:text="Button5"
android:textColor="#ffffff"
android:textSize="20dp" />
<Button
android:id="@+id/Button6"
android:layout_weight = "1"
android:layout_height="100dp"
android:layout_column="0"
android:layout_column="1"
android:layout_row="2"
android:layout_rowWeight="1"
android:layout_columnWeight="1"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:background="@drawable/mybutton"
android:onClick="Button6"
android:padding="5dp"
android:text="Button6"
android:textColor="#ffffff"
android:textSize="20dp" />
</GridLayout>
</ScrollView>
上的设备能够与roid 6的工作完美,但在装有Android 4的设备上却没有任何显示。
我该如何解决这个错误?我希望该应用程序适用于Android 4的所有设备。
警告!这不是一个广告,但如果您能告诉我是否会发生此错误,它会帮助您。 Googe播放:Gronkh Soundboard 请下载并告诉我,如果错误加重,请使用它编写您的版本。 之后,您可以卸载应用程序。
对不起,我的英语不好。
答
您可以转发此代码。我删除了一些我认为不需要的属性。希望这将有助于
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/imageView"
android:fillViewport="true">
<GridLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:columnCount="2">
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="100dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:onClick="Button1"
android:padding="3dp"
android:text="Button1"
android:textColor="#ffffff"
android:textSize="20dp" />
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="100dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:onClick="Button1"
android:padding="3dp"
android:text="Button1"
android:textColor="#ffffff"
android:textSize="20dp" />
...
</GridLayout>
</ScrollView>
链接:https://play.google.com/store/apps/details?id=com.aaron.waller.gronkhsoundboard – DaFaack
这只是可怕的设计。转储GridLayout,并学习使用GridView或RecyclerView。 –