![](/img/trans.png)
[英]How to create a framelayout inside a framelayout dynamically in android studio?
[英]Java Android create a view in FrameLayout
但是現在我有了這個
這是我的xml代碼:
<?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>
我不知道如何在中心創建一條線,並且內聯矩形和一個矩形具有兩個imageView。
請查看此用戶界面,我認為這將對您有所幫助
<?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>
請將以下代碼作為“ dummy.xml”添加到drawable文件夾中
<?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>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.