如何在android布局中创建弯曲的背景

时间:2018-03-18 04:54:21

标签: android android-layout

我在地图布局的高度和宽度上做了一些更改,得到了如下输出 click to view image 但我希望.XML文件看起来像这样 click to view image2 这就是我想要的。我在油漆区做过的向你展示

任何有关如何获得此输出的帮助都将对我有很大帮助

map.XML的代码

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@color/red"
tools:context="p.httpwww.intosanket.login">
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:map="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="300dp"
tools:context="p.httpwww.intosanket.MapsActivity" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:layout_marginTop="20dp"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableLeft="@drawable/msg"/>
<EditText
    android:layout_width="300dp"
    android:layout_height="wrap_content"
    android:hint="  E-Mail/Adresse"
    android:id="@+id/e1" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:gravity="center_horizontal"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableLeft="@drawable/lock"/>
<EditText
    android:layout_width="300dp"
    android:paddingTop="12dp"
    android:layout_height="wrap_content"
    android:hint="  Password"
    android:id="@+id/e2"/>

</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center">
<Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Sign In"
    android:id="@+id/b1"/>
<Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Register"
    android:id="@+id/b2"/>

1 个答案:

答案 0 :(得分:0)

我花了一点时间......

可能有许多其他智能方法可以做到这一点。但是我想到了以下解决方案..

诀窍是在绘画中绘制图像将其转换为svg然后转换为矢量。将该图像设置为图像视图的src

private void checkedListBox1_ItemCheck(object sender, ItemCheckEventArgs e)
        {
            if(e.CurrentValue == CheckState.Checked)
            {
                var result = MessageBox.Show("Really Remove?", "Remove", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);
                if (result == System.Windows.Forms.DialogResult.No)
                {
                    e.NewValue = e.CurrentValue;
                }
            }
        }

imageview bg.xml的src是

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FF0000"
android:orientation="vertical"
tools:context="p.httpwww.intosanket.login">

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

    <fragment xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:map="http://schemas.android.com/apk/res-auto"
        xmlns:tools="http://schemas.android.com/tools"
        android:id="@+id/map"
        android:name="com.google.android.gms.maps.SupportMapFragment"
        android:layout_width="match_parent"
        android:layout_height="300dp"
        tools:context="p.httpwww.intosanket.MapsActivity" />

    <ImageView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:scaleType="fitXY"
        android:src="@drawable/bg" />

</RelativeLayout>


<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop="20dp"
    android:gravity="center_horizontal"
    android:orientation="horizontal">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:drawableLeft="@drawable/msg" />

    <EditText
        android:id="@+id/e1"
        android:layout_width="300dp"
        android:layout_height="wrap_content"
        android:hint="  E-Mail/Adresse" />
</LinearLayout>

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

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:drawableLeft="@drawable/lock" />

    <EditText
        android:id="@+id/e2"
        android:layout_width="300dp"
        android:layout_height="wrap_content"
        android:hint="  Password"
        android:paddingTop="12dp" />

</LinearLayout>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center">

    <Button
        android:id="@+id/b1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Sign In" />

    <Button
        android:id="@+id/b2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Register" />

</LinearLayout>

Final result is