如何在Android布局中创建弯曲的背景 [英] How to create curved background in android layout

查看:69
本文介绍了如何在Android布局中创建弯曲的背景的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在地图布局的高度和宽度上做了一些更改,得到的输出如下 单击以查看图像 但我希望.XML文件看起来像这样 单击以查看图像2 这就是我想要的.我用油漆画给你看的

I had done some changes in height and width of map layout and got the output as below click to view image but i want the .XML file to look like this click to view image2 this is what i want to get. which i had done in paint to show you

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

any help on how to get this output will be great help for me

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

推荐答案

这花了我一些时间.

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

There may be many other smart ways to do it. But the following solution came into my mind..

窍门是在油漆中绘制图像,然后将其转换为svg,然后转换为矢量.将该图像设置为src进行图像查看

The trick is draw image in paint convert it to svg then to vector. Set that image as src for image view

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

imageview bg.xml的src是

the src for the imageview bg.xml is

<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="300.000000dp"
android:height="137.000000dp"
android:viewportWidth="300.000000"
android:viewportHeight="137.000000">

<group
        android:translateY="137.000000"
        android:scaleX="0.100000"
        android:scaleY="-0.100000">
    <path
        android:fillColor="#ff0000"
        android:strokeWidth="1"
        android:pathData="M2985 1328 c-38 -250 -110 -449 -230 -634 -221 -340 -558 -571 -965 -660 -68 -15 -127 -19 -295 -19 -168 0 -227 4 -295 19 -620 136 -1073 603 -1184 1221 -13 73 -14 25 -15 -587 l-1 -668 1500 0 1500 0 0 685 c0 377 -2 685 -4 685 -2 0 -7 -19 -11 -42z" />
</group>

这篇关于如何在Android布局中创建弯曲的背景的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆