如何使用XML在Android中创建此设计?
我正在尝试创建下图所示的设计 但我不知道如何开始使用XML。 我的意思是,这里举个例子,包含一个圆圈和VS单词的线。我应该如何在XML中创建它 有什么想法或例子吗如何使用XML在Android中创建此设计?,android,xml,android-layout,Android,Xml,Android Layout,我正在尝试创建下图所示的设计 但我不知道如何开始使用XML。 我的意思是,这里举个例子,包含一个圆圈和VS单词的线。我应该如何在XML中创建它 有什么想法或例子吗 我已经设计了您需要的xml文件:D 我希望这有助于: 这是snapshop: 首先,你必须下载下面的图片并添加到你的绘图目录中 下一步是复制以下xml文件: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://sch
我已经设计了您需要的xml文件:D 我希望这有助于: 这是snapshop: 首先,你必须下载下面的图片并添加到你的绘图目录中 下一步是复制以下xml文件:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:background="#fff"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="horizontal">
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center">
<ImageView
android:layout_width="150dp"
android:layout_height="150dp"
android:background="#9C9C9C" />
<ImageView
android:layout_width="150dp"
android:layout_height="150dp"
android:background="@drawable/profilemask" />
</RelativeLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Tyler Gilbert"
android:textColor="#000"
android:textSize="25dp" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal">
<ImageView
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_margin="10dp"
android:background="#9C9C9C" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Algeria"
android:textColor="#000"
android:textSize="15dp" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Level : "
android:textColor="#000"
android:textSize="20dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="A1"
android:textColor="#BF360C"
android:textSize="20dp" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
<ImageView
android:id="@+id/imgVS"
android:layout_width="match_parent"
android:layout_height="150dp"
android:background="@drawable/vs" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#f7f7f7"
android:orientation="horizontal">
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Roger Lawson"
android:textColor="#000"
android:textSize="25dp" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal">
<ImageView
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_margin="10dp"
android:background="#9C9C9C" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Algeria"
android:textColor="#000"
android:textSize="15dp" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Level : "
android:textColor="#000"
android:textSize="20dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="A1"
android:textColor="#BF360C"
android:textSize="20dp" />
</LinearLayout>
</LinearLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center">
<ImageView
android:layout_width="150dp"
android:layout_height="150dp"
android:background="#9C9C9C" />
<ImageView
android:layout_width="150dp"
android:layout_height="150dp"
android:backgroundTint="#f7f7f7"
android:background="@drawable/profilemask" />
</RelativeLayout>
</LinearLayout>
</LinearLayout>
祝你好运 您可以使用形状属性来创建类似于使用xml的pfp布局,您可以检查此已回答的问题>>如果您不理解,请告诉我,我将为您创建一个类似此布局的布局。您可以帮助我提供示例吗?您的欢迎。如果这是你问题的答案,请接受我的回答。tnx
ImageView imgVS = findViewById(R.id.imgVS);
DisplayMetrics metrics = getResources().getDisplayMetrics();
int width = metrics.widthPixels;
LinearLayout.LayoutParams map = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, (width * 132 / 362));
imgVS.setLayoutParams(map);