如何在Android中减少点之间的间距

时间:2019-01-24 01:59:18

标签: android

我通过使用自定义标签(以点的形式显示标签)添加了视图寻呼机。根据我的要求,三个点应朝下,如下图所示。

enter image description here

Code:
default_dot.xml

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item>
        <shape
            android:innerRadius="0dp"
            android:shape="ring"
            android:thickness="6dp"
            android:useLevel="false">
            <solid android:color="@android:color/darker_gray"/>
        </shape>
    </item>
</layer-list>

selected_dot.xml

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item>
        <shape
            android:innerRadius="0dp"
            android:shape="ring"
            android:thickness="6dp"
            android:useLevel="false">
            <solid android:color="@color/colorAccent"/>
        </shape>
    </item>
</layer-list>

tab_selector.xml

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">

    <item android:drawable="@drawable/selected_dot"
        android:state_selected="true"/>

    <item android:drawable="@drawable/default_dot"/>
</selector>

pagerlayout.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    xmlns:app="http://schemas.android.com/apk/res-auto">

    <LinearLayout
        android:id="@+id/mainLinearlayout"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">

    <LinearLayout
        android:id="@+id/lin_layout"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:weightSum="2">

        <TextView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="Total"
            android:textSize="20sp"
            android:layout_weight="1"/>
    <android.support.design.widget.TabLayout
        android:id="@+id/tab_layout"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        app:tabBackground="@drawable/tab_selector"

android:layout_weight="1"
        app:tabIndicatorHeight="0dp"/>


    </LinearLayout>

<Button
    android:layout_width="20dp"
    android:layout_height="4dp"
    android:background="@color/bean_green"
    android:layout_gravity="center_horizontal"/>

    </LinearLayout>

    <android.support.v4.view.ViewPager
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:id="@+id/viewPager"
        android:layout_below="@+id/mainLinearlayout"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        />



</RelativeLayout>

有了上面的代码,我在点之间得到了很多空间。但是按照要求,点应该如图所示。我尝试提供选项卡的布局和边距,但没有用。谁能告诉我如何缩小点之间的间距并精确对准右角。谢谢。

0 个答案:

没有答案