Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/visual-studio-2010/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android layout Android:RelativeLayout的正确使用_Android Layout - Fatal编程技术网

Android layout Android:RelativeLayout的正确使用

Android layout Android:RelativeLayout的正确使用,android-layout,Android Layout,我将尝试使用文本表示所需的布局: 股票名称 ========== 符号|分数 高格| 76 symbol和GOOG应在单个垂直线性布局中进行分组,且应与左侧分数对齐,76也应在单个垂直线性布局中进行分组,但应与右侧对齐 这是我的布局。我可以通过你在下面看到的方式实现它。有人知道我做错了什么吗?(这只是布局的相关部分) 我还尝试在LinearLayout中使用android:layout\u alignLeft=“@+id/relative\u layout”和android:layout\u

我将尝试使用文本表示所需的布局:

股票名称

==========

符号|分数

高格| 76

symbolGOOG应在单个垂直线性布局中进行分组,且应与左侧分数对齐76也应在单个垂直线性布局中进行分组,但应与右侧对齐

这是我的布局。我可以通过你在下面看到的方式实现它。有人知道我做错了什么吗?(这只是布局的相关部分)



我还尝试在
LinearLayout
中使用
android:layout\u alignLeft=“@+id/relative\u layout”
android:layout\u alignRight=“@+id/relative\u layout”
但没有成功

多亏了聊天室“安卓人”中的@RobinHood,我发现了这个错误:

我不得不用RelativeLayout替换内部LinearLayout,内部RelativeLayout应该从android:layout\u width=“fill\u parent”更改为android:layout\u width=“wrap\u content”


<?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" >

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal" >

    <TextView
        android:id="@+id/stock_name"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textSize="40dp" />
</LinearLayout>

<RelativeLayout
    android:id="@+id/relative_layout"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:orientation="vertical" >

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/stock_symbol" />

        <TextView
            android:id="@+id/stock_symbol"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textSize="30dp" />
    </LinearLayout>


    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:orientation="vertical" >

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/stock_score" />

        <TextView
            android:id="@+id/stock_score"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textSize="30dp" />
    </LinearLayout>
</RelativeLayout> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >

<LinearLayout
    android:id="@+id/main"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal" >

    <TextView
        android:id="@+id/stock_name"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textSize="40dp" />
</LinearLayout>

<RelativeLayout        
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"        
    android:orientation="horizontal" >

    <RelativeLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"            
        android:orientation="vertical" >

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/stock_symbol" />

        <TextView
            android:id="@+id/stock_symbol"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textSize="30dp" />
    </RelativeLayout>

    <RelativeLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:orientation="vertical" >

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/stock_score" />

        <TextView
            android:id="@+id/stock_score"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textSize="30dp" />
    </RelativeLayout>
</RelativeLayout>