English 中文(简体)
左右翼联盟
原标题:Left-right align

How it is possible to layout controls like this? enter image description here

换言之,即:<代码>TextView与左边和右边的二字一致。 当然,应当根据屏幕宽度来缩小布局。 我对如何以最明智的方式做到这一点没有任何想法。

最佳回答

您可以按照以下规定行事:

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

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

        <TextView
            android:id="@+id/textView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="TextView" />

        <TextView
            android:id="@+id/textView2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="TextView" android:layout_alignParentRight="true"/>

    </RelativeLayout>

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

        <TextView
            android:id="@+id/textView3"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="TextView" />

        <TextView
            android:id="@+id/textView4"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="TextView" android:layout_alignParentRight="true"/>

    </RelativeLayout>

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

        <TextView
            android:id="@+id/textView5"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="TextView" android:layout_alignParentLeft="true"/>

        <TextView
            android:id="@+id/textView6"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="TextView" android:layout_alignParentRight="true"/>

    </RelativeLayout>

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

        <TextView
            android:id="@+id/textView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="TextView" />

        <TextView
            android:id="@+id/textView2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="TextView" android:layout_alignParentRight="true"/>


        <TextView
            android:id="@+id/textView3"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="TextView"  android:layout_below="@+id/textView1"/>

        <TextView
            android:id="@+id/textView4"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="TextView" android:layout_alignParentRight="true"
            android:layout_below="@+id/textView2"/>


        <TextView
            android:id="@+id/textView5"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="TextView" android:layout_alignParentLeft="true"
             android:layout_below="@+id/textView3"/>

        <TextView
            android:id="@+id/textView6"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="TextView" android:layout_alignParentRight="true"
            android:layout_below="@+id/textView4"/>

</RelativeLayout>

你们可以使用相关语言。 接着,你的发言像你这样。

 android:layout_alignParentRight="true"

这里指的是此类布局:

rel=“nofollow”> 相容性

你们可以把整个观点变成一个相对的理论,并使用布局——alignParentLeft、布局_alignParent 权利,将文字观与左侧和观点的权利挂钩,然后做定论。 在每个侧面保持案文调查的基准。 接下来是下行文调查。

或者,你可以使用线虫来布局(width=“match”),然后使用上述同样方法将红箱变成相关的解甲。

然而,我建议你检查每一类型的布局,以便了解每个集装箱的特性,然后决定哪些是最适合您整体看法的,但铭记,你对屏幕的更深入看法/解释将对某些装置产生效果。

你们可以使用相关语言,但同样一种观点认为,这两种观点应当有固定的宽度。 如果你确信,正确的看法会比一些宽度高,那么你也可以分配包裹——继续留宿,但如果第二种观点可能采用充分的屏幕宽度,那么就有必要为布局分配一些固定的宽度。

So set LayoutParams to Left and Right view as follows: LeftView:

Layout_width=Fuller_, Layout_hala=wrap_content,puout_toLeftOf=@+id/rightView,

第二维兹:

Layout_width=wrap_content, Layout_height=wrap_content, layout_alignParentRight= true





相关问题
Android - ListView fling gesture triggers context menu

I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

Android intent filter for a particular file extension?

I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...

Android & Web: What is the equivalent style for the web?

I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...

TiledLayer equivalent in Android [duplicate]

To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?

Using Repo with Msysgit

When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...

Android "single top" launch mode and onNewIntent method

I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...

From Web Development to Android Development

I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...

热门标签