Datepicker底部不可见

Datepicker底部不可见

本文介绍了Android:Datepicker底部不可见的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要在版式中添加一个DatePicker小部件.

我正在使用微调器类型.

但是小部件的一小部分是不可见的.

我将布局高度用作wrap_content

我尝试更改layout_height属性值,但没有用.

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.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"
    tools:context=".StartSaving">

    <android.support.v7.widget.Toolbar
        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:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@color/white"

        app:layout_constraintTop_toTopOf="parent">



            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:gravity="center"
                android:id="@+id/toolbar_title"
                android:text="TITLE"
                android:fontFamily="@font/montserratsemibold"

                android:textColor="#42a5f5"
                android:textSize="32sp"
                android:layout_marginBottom="0dp"/>

    </android.support.v7.widget.Toolbar>
    <View
        android:layout_width="match_parent"
        android:layout_height="0.5dp"
        android:id="@+id/toolbar_bottom_line"
        app:layout_constraintTop_toBottomOf="@id/toolbar"
        android:background="#42a5f5"/>
    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/text_branding"
        android:gravity="center"
        android:textColor="#20336b"
        android:textSize="24sp"
        android:text="TEXT 2"
        android:layout_marginTop="10dp"
        app:layout_constraintTop_toBottomOf="@id/toolbar_bottom_line"/>
    <RadioGroup
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/radio_group"
        android:paddingLeft="40dp"
        android:layout_marginTop="20dp"
        app:layout_constraintTop_toBottomOf="@id/text_branding"
        >
        <RadioButton
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="left"
            android:textSize="26sp"
            android:text="Option 1"/>
        <RadioButton
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="left"
            android:textSize="26sp"
            android:text="Option 2"/>
    </RadioGroup>
    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"

        android:id="@+id/enter_detail"
        android:hint="Enter Detail"
        android:padding="20dp"
        android:inputType="number"
        android:textColorHint="#42a5f5"
        android:textColor="@color/title_black"
        app:layout_constraintTop_toBottomOf="@id/radio_group"/>
    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:layout_constraintTop_toBottomOf="@id/enter_detail"
        android:id="@+id/select_date_title"
        android:text="Select Date"
        android:textSize="24sp"
        android:textColor="@color/title_black"
        android:padding="10dp"/>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/date"
        app:layout_constraintTop_toBottomOf="@id/select_date_title"
        >
    <DatePicker
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"

        android:datePickerMode="spinner"
        android:calendarTextColor="@color/title_black"

        android:layout_marginHorizontal="15dp"
        android:backgroundTint="#42a5f5"
        android:background="@color/white"
        android:outlineSpotShadowColor="@color/title_black">

    </DatePicker>
    </LinearLayout>

        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/save_button"
            app:layout_constraintTop_toBottomOf="@id/date"
            app:layout_constraintLeft_toLeftOf="parent"
            app:layout_constraintRight_toRightOf="parent"
            android:text="SAVE"
            android:textSize="20sp"
            android:textColor="@color/white"

            android:backgroundTint="#42a5f5"
            android:padding="5dp"
            android:layout_margin="20dp"/>

    </android.support.constraint.ConstraintLayout>

这是我得到的输出:

解决方案

尝试使用app:layout_constraintBottom_toBottomOf="parent"表示保存按钮",为了安全起见,我也应该给出app:layout_constraintBottom_toTopOf="@id/save_button"表示日期"(尽管可能不需要)./p>

I am adding a DatePicker widget in my Layout.

I am using spinner type.

But a small part of widget is not visible.

I am using layout height as wrap_content

I have tried changing layout_height attribute values but of no use.

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.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"
    tools:context=".StartSaving">

    <android.support.v7.widget.Toolbar
        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:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@color/white"

        app:layout_constraintTop_toTopOf="parent">



            <TextView
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:gravity="center"
                android:id="@+id/toolbar_title"
                android:text="TITLE"
                android:fontFamily="@font/montserratsemibold"

                android:textColor="#42a5f5"
                android:textSize="32sp"
                android:layout_marginBottom="0dp"/>

    </android.support.v7.widget.Toolbar>
    <View
        android:layout_width="match_parent"
        android:layout_height="0.5dp"
        android:id="@+id/toolbar_bottom_line"
        app:layout_constraintTop_toBottomOf="@id/toolbar"
        android:background="#42a5f5"/>
    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/text_branding"
        android:gravity="center"
        android:textColor="#20336b"
        android:textSize="24sp"
        android:text="TEXT 2"
        android:layout_marginTop="10dp"
        app:layout_constraintTop_toBottomOf="@id/toolbar_bottom_line"/>
    <RadioGroup
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/radio_group"
        android:paddingLeft="40dp"
        android:layout_marginTop="20dp"
        app:layout_constraintTop_toBottomOf="@id/text_branding"
        >
        <RadioButton
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="left"
            android:textSize="26sp"
            android:text="Option 1"/>
        <RadioButton
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="left"
            android:textSize="26sp"
            android:text="Option 2"/>
    </RadioGroup>
    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"

        android:id="@+id/enter_detail"
        android:hint="Enter Detail"
        android:padding="20dp"
        android:inputType="number"
        android:textColorHint="#42a5f5"
        android:textColor="@color/title_black"
        app:layout_constraintTop_toBottomOf="@id/radio_group"/>
    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:layout_constraintTop_toBottomOf="@id/enter_detail"
        android:id="@+id/select_date_title"
        android:text="Select Date"
        android:textSize="24sp"
        android:textColor="@color/title_black"
        android:padding="10dp"/>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/date"
        app:layout_constraintTop_toBottomOf="@id/select_date_title"
        >
    <DatePicker
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"

        android:datePickerMode="spinner"
        android:calendarTextColor="@color/title_black"

        android:layout_marginHorizontal="15dp"
        android:backgroundTint="#42a5f5"
        android:background="@color/white"
        android:outlineSpotShadowColor="@color/title_black">

    </DatePicker>
    </LinearLayout>

        <Button
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/save_button"
            app:layout_constraintTop_toBottomOf="@id/date"
            app:layout_constraintLeft_toLeftOf="parent"
            app:layout_constraintRight_toRightOf="parent"
            android:text="SAVE"
            android:textSize="20sp"
            android:textColor="@color/white"

            android:backgroundTint="#42a5f5"
            android:padding="5dp"
            android:layout_margin="20dp"/>

    </android.support.constraint.ConstraintLayout>

This is output I get:

解决方案

Try app:layout_constraintBottom_toBottomOf="parent" for "save_button" and for safety I would have also given app:layout_constraintBottom_toTopOf="@id/save_button" for "date" (although it may not be required).

这篇关于Android:Datepicker底部不可见的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-31 14:21