【问题标题】:text view is not showing up in relative layout文本视图未显示在相对布局中
【发布时间】:2014-12-23 15:45:57
【问题描述】:

我有一个包含图像和文本视图的相对布局的屏幕。我正在尝试添加一个文本视图,但它没有显示出来。我找不到原因。这是我的整个 xml:

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

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent" >

        <TextView
            android:id="@+id/textView1"
            android:layout_width="wrap_content"
            android:layout_height="50dp"
            android:layout_alignParentLeft="true"
            android:layout_alignParentRight="true"
            android:layout_alignParentTop="true"
            android:background="@drawable/orangestrip"
            android:gravity="left|center"
            android:text="Choose your flag, Pay in your Home currency"
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:textColor="#ffffff" />

        <TextView
            android:id="@+id/textView4"
            android:layout_width="wrap_content"
            android:layout_height="50dp"
            android:layout_alignParentLeft="true"
            android:layout_alignParentRight="true"
            android:layout_below="@+id/textView1"
            android:background="@drawable/orangestrip"
            android:gravity="left|center"
            android:text="اختيار العلم الخاص بك، ودفع بالعملة المحلية الخاصة بك"
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:textColor="#ffffff" />

        <Button
            android:id="@+id/button1"
            android:layout_width="wrap_content"
            android:layout_height="60dp"
            android:layout_alignParentBottom="true"
            android:layout_alignParentLeft="true"
            android:layout_alignParentRight="true"
            android:background="@drawable/stripblue"
            android:gravity="center"
            android:text="Cancel"
            android:textColor="#ffffff" />

        <RelativeLayout
            android:id="@+id/relativeLayout2"
            android:layout_width="450dp"
            android:layout_height="500dp"
            android:layout_above="@+id/button1"
            android:layout_alignParentLeft="true"
            android:layout_alignParentRight="true"
            android:layout_below="@+id/textView4"
            android:background="@drawable/imageborder" >

            <RelativeLayout
                android:id="@+id/relativeLayout1"
                android:layout_width="450dp"
                android:layout_height="500dp"
                android:layout_alignParentLeft="true"
                android:layout_centerVertical="true"
                android:background="@drawable/imageborder" >

                <ImageButton
                    android:id="@+id/imageButton1"
                    android:layout_width="400dp"
                    android:layout_height="320dp"
                    android:layout_above="@+id/textView2"
                    android:layout_centerHorizontal="true"
                    android:layout_marginBottom="17dp" />

                <TextView
                    android:id="@+id/textView2"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignLeft="@+id/imageButton1"
                    android:layout_alignParentBottom="true"
                    android:layout_marginLeft="85dp"
                    android:text="curr"
                    android:textAppearance="?android:attr/textAppearanceLarge"
                    android:textSize="35sp"
                    android:textStyle="bold" />

<TextView
    android:id="@+id/textView5"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_above="@+id/textView2"
    android:layout_alignLeft="@+id/textView2"
    android:gravity="center"
    android:text="rate"
    android:textColor="@android:color/black" />

            </RelativeLayout>

            <RelativeLayout
                android:layout_width="450dp"
                android:layout_height="500dp"
                android:layout_alignParentRight="true"
                android:layout_alignTop="@+id/relativeLayout1"
                android:background="@drawable/imageborder" >

                <ImageButton
                    android:id="@+id/imageButton2"
                    android:layout_width="400dp"
                    android:layout_height="320dp"
                    android:layout_above="@+id/textView3"
                    android:layout_centerHorizontal="true"
                    android:layout_marginBottom="16dp"
                    android:background="@drawable/uae" />

                <TextView
                    android:id="@+id/textView3"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignParentBottom="true"
                    android:layout_alignRight="@+id/imageButton2"
                    android:layout_marginRight="123dp"
                    android:text="curr"
                    android:textAppearance="?android:attr/textAppearanceLarge"
                    android:textSize="35sp"
                    android:textStyle="bold" />

            </RelativeLayout>
        </RelativeLayout>

        <ImageView
            android:id="@+id/imageView1"
            android:layout_width="200dp"
            android:layout_height="200dp"
            android:layout_above="@+id/relativeLayout2"
            android:layout_alignParentRight="true"
            android:background="@null"
            android:src="@drawable/mashreqlogosmall" />

    </RelativeLayout>

</LinearLayout>

这是我试图添加文本视图但它没有显示的相对布局...带有 id textview5 的文本视图没有显示。

<RelativeLayout
                android:id="@+id/relativeLayout1"
                android:layout_width="450dp"
                android:layout_height="500dp"
                android:layout_alignParentLeft="true"
                android:layout_centerVertical="true"
                android:background="@drawable/imageborder" >

                <ImageButton
                    android:id="@+id/imageButton1"
                    android:layout_width="400dp"
                    android:layout_height="320dp"
                    android:layout_above="@+id/textView2"
                    android:layout_centerHorizontal="true"
                    android:layout_marginBottom="17dp" />

                <TextView
                    android:id="@+id/textView2"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignLeft="@+id/imageButton1"
                    android:layout_alignParentBottom="true"
                    android:layout_marginLeft="85dp"
                    android:text="curr"
                    android:textAppearance="?android:attr/textAppearanceLarge"
                    android:textSize="35sp"
                    android:textStyle="bold" />

<TextView
    android:id="@+id/textView5"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_above="@+id/textView2"
    android:layout_alignLeft="@+id/textView2"
    android:gravity="center"
    android:text="rate"
    android:textColor="@android:color/black" />

            </RelativeLayout>

请帮忙..

【问题讨论】:

    标签: android android-layout textview android-linearlayout android-relativelayout


    【解决方案1】:

    这样试试

     <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/relativeLayout1"
        android:layout_width="450dp"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_centerVertical="true"
        android:background="@drawable/ic_launcher" >
    
        <ImageButton
            android:id="@+id/imageButton1"
            android:layout_width="400dp"
            android:layout_height="320dp"
            android:layout_above="@+id/textView5"
            android:layout_centerHorizontal="true"
            android:layout_marginBottom="17dp" />
    
        <TextView
            android:id="@+id/textView2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignLeft="@+id/imageButton1"
            android:layout_alignParentBottom="true"
            android:layout_marginLeft="85dp"
            android:text="curr"
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:textSize="35sp"
            android:textStyle="bold" />
    
        <TextView
            android:id="@+id/textView5"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_above="@+id/textView2"
            android:layout_alignLeft="@+id/textView2"
            android:gravity="center"
            android:text="rate"
            android:textColor="@android:color/black" />
    
    </RelativeLayout>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-05-10
      • 2015-12-29
      • 1970-01-01
      • 2011-05-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多