user7652543
user7652543

Reputation:

Java Android create a view in FrameLayout

Hi I want to create a view which look like this : enter image description here

But now I have this

enter image description here

and this is my xml code :

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="pl..smok.ui.activity.SettingsActivity">

    <FrameLayout
        android:id="@+id/top_bar_container"
        android:layout_width="match_parent"
        android:layout_height="70dp"
        android:layout_alignParentTop="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true" />

    <LinearLayout
        android:id="@+id/change_orieientation_screen"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@id/top_bar_container"
        android:layout_marginTop="10dp"
        android:clickable="true">

        <TextView
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="10dp"
            android:text="Zmień orientację ekranu"
            android:textSize="20dp" />

</RelativeLayout>

I don't know how I can create a line in center, and inline rectangle and a rectangle have two imageView.

Upvotes: 0

Views: 289

Answers (1)

Rakshith Kumar
Rakshith Kumar

Reputation: 869

Please look into this UI, I think it will be helpful for you

    <?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_marginTop="24dp"
    android:orientation="vertical">
    <View
        android:layout_width="match_parent"
        android:layout_height="1dp"
        android:layout_gravity="center"
        android:background="@android:color/black" />
    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@drawable/dummy"
        android:layout_gravity="center"
        android:padding="2dp"
        android:orientation="horizontal">

       <ImageView
        android:layout_width="wrap_content"
        android:layout_height="40dp"
        android:src="@mipmap/ic_launcher" />

        <ImageView
        android:layout_width="wrap_content"
        android:layout_height="40dp"
        android:src="@mipmap/ic_launcher" />
    </LinearLayout>

</FrameLayout>

please add below code into drawable folder as a "dummy.xml"

<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <solid android:color="#ffffffff"/>

    <stroke android:width="3dp"
        android:color="#ff000000" />

    <padding android:left="1dp"
        android:top="1dp"
        android:right="1dp"
        android:bottom="1dp" />

    <corners android:bottomRightRadius="7dp"
        android:bottomLeftRadius="7dp"
        android:topLeftRadius="7dp"
        android:topRightRadius="7dp" />
</shape>

Upvotes: 1

Related Questions