如何在线性布局中将跳跃和下一个对齐

时间:2019-12-21 13:38:32

标签: android android-layout

我想要这样的东西 enter image description here 但是通过以下代码,我得到了

enter image description here 我尝试了各种方法,要么指示器在线性布局的末端消失,要么不显示。我需要帮助。谢谢

注意:我使用了implementation 'com.ogaclejapan.smarttablayout:library:1.2.1@aar'

所以请首先运行您的代码并提出solution.my谦虚的请求

 <LinearLayout
    android:id="@+id/viewPagerCountDots"
    android:layout_width="match_parent"
    android:layout_height="@dimen/pager_height"
    android:layout_above="@+id/ll_footer"
    android:layout_marginBottom="12dp"
    android:layout_alignParentLeft="true"
    android:gravity="center"
    android:orientation="horizontal" />
//skip
<com.gc.materialdesign.views.ButtonFlat
    android:id="@+id/skip"
    android:layout_width="72dp"
    android:layout_height="wrap_content"
    android:layout_above="@id/viewPagerCountDots"
    android:layout_weight="0.5"
    android:text="Skip" />
//next
<com.gc.materialdesign.views.ButtonFlat
    android:id="@+id/next"
    android:layout_width="72dp"
    android:layout_height="wrap_content"
    android:layout_above="@id/viewPagerCountDots"
    android:layout_alignParentEnd="true"
    android:layout_weight="0.5"
    android:text="Next" />

3 个答案:

答案 0 :(得分:0)

使用(Skip button

android:gravity="bottom|end" // to skip button 

并使用(next button):

android:gravity="bottom|start" //  to next button !

答案 1 :(得分:0)

跳过按钮

android:layout_gravity="bottom|end" 

,并用于下一个按钮

android:layout_gravity="bottom|start" 

答案 2 :(得分:0)

以下是解决方案。.我经过很多努力后才发现它,并且它按要求工作。.

<?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"
xmlns:app="http://schemas.android.com/apk/res-auto">


<androidx.viewpager.widget.ViewPager
    android:id="@+id/pager_introduction"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_above="@id/constraint" />

<androidx.constraintlayout.widget.ConstraintLayout
    android:id="@+id/constraint"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_above="@id/ll_footer"
    android:layout_marginBottom="30dp">

    <LinearLayout
        android:id="@+id/viewPagerCountDots"
        android:layout_width="wrap_content"
        android:layout_height="@dimen/pager_height"
        android:layout_marginTop="6dp"
        android:orientation="horizontal"
        app:layout_constraintEnd_toStartOf="@id/next"
        app:layout_constraintLeft_toRightOf="@id/skip"
        app:layout_constraintRight_toLeftOf="@id/next"
        app:layout_constraintStart_toEndOf="@id/skip"
        app:layout_constraintTop_toBottomOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        tools:ignore="MissingConstraints"

        ></LinearLayout>

    <TextView
        android:id="@+id/skip"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_above="@id/viewPagerCountDots"
        android:text="Skip"
        app:layout_constraintEnd_toStartOf="@id/viewPagerCountDots"
        app:layout_constraintHorizontal_chainStyle="packed"


        app:layout_constraintStart_toStartOf="@id/constraint"
        tools:ignore="MissingConstraints" />

    <TextView
        android:id="@+id/next"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_above="@id/viewPagerCountDots"
        android:layout_alignParentEnd="true"
        android:text="Next"
        app:layout_constraintEnd_toEndOf="@id/constraint"
        app:layout_constraintStart_toEndOf="@id/viewPagerCountDots"
        tools:ignore="MissingConstraints" />

</androidx.constraintlayout.widget.ConstraintLayout>
<LinearLayout
    android:layout_alignParentBottom="true"
    android:layout_alignParentLeft="true"
    android:id="@+id/ll_footer"
    android:layout_width="match_parent"
    android:layout_height="50dp"
    android:orientation="vertical"

    >

    <Button
        android:id="@+id/btn_get_started"
        style="?android:attr/borderlessButtonStyle"
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:background="#00B359"
        android:text="Get Started"
        android:textAllCaps="false"
        android:textColor="@color/white"
        android:textSize="@dimen/button_text"
        android:visibility="gone"
        />


</LinearLayout>