简体   繁体   English

在Android中的activity_main.xml页面中发出警报

[英]Alert in activity_main.xml page in android

I have an alert dialog in activity_main.xml page. 我在activity_main.xml页面中有一个警报对话框。

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 : 在我的xml页面的这一行中:

android:layout_alignLeft="@+id/button1"

My xml code below. 我的xml代码如下。

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). 问题是Android 4.2(API级别17)支持layout_alignStart 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. 该警报只是一个警告, layout_alignLeft可以正常工作,但是如果它困扰您,则可以将其添加到代码中,但请保留layout_alignLeft以获得兼容性。

You can read about it here . 你可以在这里阅读。

Dialogs come on top of the UI. 对话框位于UI顶部。 See documentation here : http://developer.android.com/guide/topics/ui/dialogs.html 在此处查看文档: http : //developer.android.com/guide/topics/ui/dialogs.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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