XML 布局设计和代码不匹配

用户5172381

我的 xml 布局设计不是我的代码应该是的。我没有动态改变任何东西。

代码:

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


<android.support.v7.widget.CardView
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

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

        <TextView
            android:id="@+id/rollnoT"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerHorizontal="true"
            android:layout_centerVertical="true"
            android:text="5"
            android:textSize="200sp"/>

        <TextView
            android:id="@+id/nameT"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_below="@+id/rollnoT"
            android:layout_centerHorizontal="true"
            android:layout_marginTop="19dp"
            android:text="abc"
            android:textSize="30sp"/>

        <TextView
            android:id="@+id/cmtT"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_centerHorizontal="true"
            android:layout_centerVertical="true"
            android:alpha="0"
            android:background="@android:color/holo_red_light"
            android:gravity="center_vertical|center_horizontal"
            android:text="Ab"
            android:textSize="200sp"/>
    </RelativeLayout>
</android.support.v7.widget.CardView>

我的设计:

在此处输入图片说明

看“abc”它应该低于'5'而不是在中间。我已经设置,android:layout_below="@+id/rollnoT"但它仍然显示在中间。

请帮我解决这个问题。

萨坦德·库马尔

试试这个

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

    <android.support.v7.widget.CardView
        android:layout_width="match_parent"
        android:layout_height="match_parent">

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

            <TextView
                android:id="@+id/rollnoT"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerHorizontal="true"
                android:layout_centerVertical="true"
                android:text="5"
                android:textSize="200sp"/>

            <TextView
                android:id="@+id/nameT"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_below="@id/rollnoT"
                android:layout_centerHorizontal="true"
                android:layout_marginTop="19dp"
                android:text="abc"
                android:textSize="30sp"/>

            <TextView
                android:id="@+id/cmtT"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerHorizontal="true"
                android:layout_centerVertical="true"
                android:alpha="0"
                android:background="@android:color/holo_red_light"
                android:gravity="center_vertical|center_horizontal"
                android:text="Ab"
                android:textSize="200sp"/>
        </RelativeLayout>
    </android.support.v7.widget.CardView>

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章