简体   繁体   中英

Alert in activity_main.xml page in android

I have an alert dialog in activity_main.xml page.

I have tried quite a few combinations and am unable to resolve the alert.

This is beginning to make me believe my structure as a whole is not correct.

This seems like there should be an easy fix.

What am I missing ?

Alert:

Consider adding android:layout_alignStart="@+id/button1" to 
better support right-to-left layouts

In this line of my xml page :

android:layout_alignLeft="@+id/button1"

My xml code below.

Thanks in advance.

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >

    <RelativeLayout
        android:id="@+id/ccmexRelativeLayout"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="#00688B"
        android:gravity="top"
        android:paddingBottom="@dimen/activity_vertical_margin"
        android:paddingLeft="@dimen/activity_horizontal_margin"
        android:paddingRight="@dimen/activity_horizontal_margin"
        android:paddingTop="@dimen/activity_vertical_margin"
        tools:context=".MainActivity" >

        <ImageView
            android:id="@+id/image"
            android:layout_width="300dp"
            android:layout_height="500dp"
            android:layout_alignParentTop="true"
            android:layout_centerHorizontal="true"
            android:background="@drawable/collage"
            android:contentDescription="@null" />

        <Button
            android:id="@+id/button1"
            android:layout_width="wrap_content"
            android:layout_height="40dp"
            android:layout_marginTop="30dp"
            android:background="#EAEAAE"
            android:text="@string/welcome"
            android:textColor="#5C3317"
            android:textSize="20sp"
            android:textStyle="bold"
            android:width="150sp" />

        <Button
            android:id="@+id/button2"
            android:layout_width="wrap_content"
            android:layout_height="40dp"
            android:layout_alignLeft="@+id/button1"
            android:layout_below="@+id/button1"
            android:layout_marginTop="14dp"
            android:background="#EAEAAE"
            android:text="@string/work"
            android:textColor="#5C3317"
            android:textSize="20sp"
            android:textStyle="bold"
            android:width="150sp" />


        <TextView
            android:id="@+id/textView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignBottom="@+id/image"
            android:layout_alignRight="@+id/image"
            android:text="@string/group"
            android:textColor="@color/text_color"
            android:textSize="12sp" />
    </RelativeLayout>

</ScrollView>

The problem is layout_alignStart is supported from Android 4.2 (API level 17). The alert is just a warning, layout_alignLeft works just fine but if it bothers you then you can add it to your code but keep layout_alignLeft for compatibility.

You can read about it here .

Dialogs come on top of the UI. See documentation here : http://developer.android.com/guide/topics/ui/dialogs.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM