2016-07-05 5 views
3

Я делаю приложение с основными фразами (я упомянул об этом в своем предыдущем вопросе), и я все потерял. Однако эмулятор не отображает приложение правильно. Это предварительный просмотр в студии:Android Emulator не отображает приложение правильно (Android Studio)

enter image description here

И это то, что эмулятор отображает:

enter image description here

Там нет никаких ошибок в пределах моего кода, и все компоненты Android студийные своевременно. Что происходит? Это мой XML:

<?xml version="1.0" encoding="utf-8"?> 
<GridLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="match_parent"> 

    <Button 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_column="0" 
     android:layout_row="0" 
     android:layout_columnWeight="1" 
     android:layout_rowWeight="1" 
     android:layout_gravity="fill" 
     android:text="Hello" 
     android:onClick="buttonTapped" 
     android:id="@+id/button" /> 

    <Button 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_column="1" 
     android:layout_row="0" 
     android:layout_columnWeight="1" 
     android:layout_rowWeight="1" 
     android:layout_gravity="fill" 
     android:text="How are you?" 
     android:onClick="buttonTapped" 
     android:id="@+id/howareyou" /> 

    <Button 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_column="0" 
     android:layout_row="1" 
     android:layout_columnWeight="1" 
     android:layout_rowWeight="1" 
     android:layout_gravity="fill" 
     android:text="Good Evening" 
     android:onClick="buttonTapped" 
     android:id="@+id/goodevening" /> 

    <Button 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_column="1" 
     android:layout_row="1" 
     android:layout_columnWeight="1" 
     android:layout_rowWeight="1" 
     android:layout_gravity="fill" 
     android:text="Please" 
     android:onClick="buttonTapped" 
     android:id="@+id/please" /> 

    <Button 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_column="0" 
     android:layout_row="2" 
     android:layout_columnWeight="1" 
     android:layout_rowWeight="1" 
     android:layout_gravity="fill" 
     android:text="My name is..." 
     android:onClick="buttonTapped" 
     android:id="@+id/mynameis" /> 

    <Button 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_column="1" 
     android:layout_row="2" 
     android:layout_columnWeight="1" 
     android:layout_rowWeight="1" 
     android:layout_gravity="fill" 
     android:text="Do you &#10; speak English?" 
     android:onClick="buttonTapped" 
     android:id="@+id/doyouspeakenglish" /> 

    <Button 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_column="0" 
     android:layout_row="3" 
     android:layout_columnWeight="1" 
     android:layout_rowWeight="1" 
     android:layout_gravity="fill" 
     android:text="Welcome" 
     android:onClick="buttonTapped" 
     android:id="@+id/welcome" /> 

    <Button 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_column="1" 
     android:layout_row="3" 
     android:layout_columnWeight="1" 
     android:layout_rowWeight="1" 
     android:layout_gravity="fill" 
     android:text="I live in..." 
     android:onClick="buttonTapped" 
     android:id="@+id/ilivein" /> 

</GridLayout> 
+1

Опубликуйте свой XML-код. –

+0

Я скопировал ваш xml и протестировал его. Он работает отлично. –

ответ

3

Когда макет тяжести установлен в заливки, он заполняет его контейнер. Вот почему он отображает только первую кнопку.

Возможно, в текущем эмуляторе возникли проблемы с отображением gridlayout, поэтому корневая компоновка стала контейнером кнопки.

Я пробовал ваш XML-файл, и он отлично работает на эмулированных и реальных устройствах.

+0

Вы были правы! Я только что создал новый проект, переместил код, и он сработал. Я думал, что моя проблема не будет исправлена, но теперь она исправлена. Благодаря! –