TextView和EditText无法在Android布局中呈现

时间:2016-05-10 20:20:49

标签: android xml android-layout android-edittext textview

我试图创建一个简单的游戏,但我遇到了布局问题。下面是我的Xml代码,我没有任何错误但是当我尝试运行它时(文本view_bet和编辑文本下注两个不会出现在模拟器中,它们都应该出现在底部模拟器。感谢任何帮助。

XML代码

<?xml version="1.0" encoding="utf-8"?>
 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:background="#CD853F"
   android:orientation="vertical" >

<ac.nott.Game
    android:id="@+id/game"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
     android:paddingBottom="1000dp" />

<TextView
    android:id="@+id/stack1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true"
    android:layout_marginLeft="30dp"
    android:padding="10dp"
    android:text="@string/fiftey"
    android:textColor="#000000"
    android:textSize="50sp" />

<TextView
    android:id="@+id/stack2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentRight="true"
    android:layout_alignParentTop="true"
    android:layout_marginRight="34dp"
    android:padding="10dp"
    android:text="@string/fiftey"
    android:textColor="#000000"
    android:textSize="50sp" />

<Button
    android:id="@+id/go"
    android:layout_width="wrap_content"
    android:layout_height="40dp"
    android:layout_alignParentBottom="true"
    android:layout_centerHorizontal="true"
    android:text="@string/button2_text"
    android:textColor="#000000" />

<TextView
    android:id="@+id/betOne"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignBottom="@+id/go"
    android:layout_alignLeft="@+id/stack2"
    android:layout_alignRight="@+id/stack2"
    android:background="#FFFFCC"
   android:text="@string/text4"
    android:textColor="#000000" />

<EditText
    android:id="@+id/betTwo"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignBottom="@+id/betOne"
    android:layout_alignLeft="@+id/stack1"
    android:layout_alignTop="@+id/betOne"
    android:layout_toLeftOf="@+id/Info"
    android:background="#FFFFCC"
    android:inputType="text"
    android:textColor="#000000" />


<TextView
    android:id="@+id/Info"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_above="@+id/go"
    android:layout_marginBottom="36dp"
    android:layout_marginLeft="20dp"
    android:layout_toRightOf="@+id/stack1"
    android:textColor="#000000"
    android:textSize="20sp" />

1 个答案:

答案 0 :(得分:0)

改变这两个。 android:layout_alignBottom表示视图的底部将处于相同的加号,因此可能会重叠。你可能想要android:layout_above

<TextView
android:id="@+id/betOne"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@id/go"
android:layout_alignLeft="@+id/stack2"
android:layout_alignRight="@+id/stack2"
android:background="#FFFFCC"
android:text="@string/text4"
android:textColor="#000000" />

<EditText
android:id="@+id/betTwo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@id/betOne"
android:layout_alignLeft="@+id/stack1"
android:layout_alignTop="@+id/betOne"
android:layout_toLeftOf="@+id/Info"
android:background="#FFFFCC"
android:inputType="text"
android:textColor="#000000" />