简体   繁体   English

如何在选项卡视图中实现圆形 UI android java

[英]How to achieve circular UI in tab view android java

I am working on a project for a client and they gave me the UI where I have to implement a certain tab like layout and I was wondering how to achieve this kind of tab on android.我正在为客户开发一个项目,他们给了我 UI,我必须在其中实现某个选项卡,如布局,我想知道如何在 android 上实现这种选项卡。 I have attached the image below.我附上了下面的图片。 Any help would be much appreciated.任何帮助将非常感激。

The snapshot of what I want to achieve我想要实现的快照

If you don't mind then this answer is not based on circular UI in tab view android java but it almost fulfills your need.如果您不介意,那么此答案并非基于选项卡视图 android java 中的圆形 UI,但它几乎可以满足您的需求。

Output (please don't mind app name): Output(请不要介意应用名称):

You can achieve your need by using this XML code:您可以使用此 XML 代码来满足您的需求:

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 
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:layout_gravity="center"
android:background="#EDFAFF"
tools:context=".MainActivity">


<ImageView
    android:id="@+id/personalInfoTab"
    android:layout_width="30dp"
    android:layout_height="30dp"
    android:layout_marginStart="50dp"
    android:layout_marginTop="30dp"
    android:contentDescription="@string/app_name"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:srcCompat="@drawable/radio_btn_checked"
    app:tint="@color/black" />

<ProgressBar
    android:id="@+id/personalInfoProgress"
    style="?android:attr/progressBarStyleHorizontal"
    android:layout_width="120dp"
    android:layout_height="wrap_content"
    android:layout_marginStart="-4dp"
    android:max="100"
    app:layout_constraintBottom_toBottomOf="@+id/personalInfoTab"
    app:layout_constraintStart_toEndOf="@+id/personalInfoTab"
    app:layout_constraintTop_toTopOf="@+id/personalInfoTab" />

<ImageView
    android:id="@+id/paymentTab"
    android:layout_width="30dp"
    android:layout_height="30dp"
    app:layout_constraintBottom_toBottomOf="@+id/personalInfoProgress"
    app:layout_constraintEnd_toStartOf="@+id/paymentProgressBar"
    app:layout_constraintStart_toEndOf="@+id/personalInfoProgress"
    app:layout_constraintTop_toTopOf="@+id/personalInfoProgress"
    app:srcCompat="@drawable/ic_baseline_circle_24"
    app:tint="#353535" />

<ProgressBar
    android:id="@+id/paymentProgressBar"
    style="?android:attr/progressBarStyleHorizontal"
    android:layout_width="120dp"
    android:layout_height="wrap_content"
    app:layout_constraintBottom_toBottomOf="@+id/paymentTab"
    app:layout_constraintEnd_toStartOf="@+id/confirmationTab"
    app:layout_constraintTop_toTopOf="@+id/paymentTab" />

<ImageView
    android:id="@+id/confirmationTab"
    android:layout_width="30dp"
    android:layout_height="30dp"
    android:layout_marginEnd="50dp"
    app:layout_constraintBottom_toBottomOf="@+id/paymentProgressBar"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintTop_toTopOf="@+id/paymentProgressBar"
    app:srcCompat="@drawable/ic_baseline_circle_24"
    app:tint="#353535" />

<TextView
    android:id="@+id/textView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Personal Info"
    app:layout_constraintEnd_toStartOf="@+id/personalInfoProgress"
    app:layout_constraintStart_toStartOf="@+id/personalInfoTab"
    app:layout_constraintTop_toBottomOf="@+id/personalInfoTab" />

<TextView
    android:id="@+id/textView2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Payment"
    app:layout_constraintEnd_toStartOf="@+id/paymentProgressBar"
    app:layout_constraintStart_toEndOf="@+id/personalInfoProgress"
    app:layout_constraintTop_toBottomOf="@+id/paymentTab" />

<TextView
    android:id="@+id/textView3"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Confirmation"
    app:layout_constraintEnd_toEndOf="@+id/confirmationTab"
    app:layout_constraintStart_toEndOf="@+id/paymentProgressBar"
    app:layout_constraintTop_toBottomOf="@+id/confirmationTab" />

//frameLayout for your fragments
<FrameLayout
    android:layout_width="0dp"
    android:layout_height="0dp"
    android:layout_marginStart="16dp"
    android:layout_marginEnd="16dp"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toBottomOf="@+id/textView2">

 </FrameLayout>
 </androidx.constraintlayout.widget.ConstraintLayout>

Now you can increase the progress and you can use Fragments for different pages ie: Personal Info , Payment , Confirmation现在您可以增加进度,您可以将片段用于不同的页面,即:个人信息付款确认

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM