如何覆盖日期选择器的高度和宽度以填充父布局 [英] how to override height and width of date picker to fill the parent layout
本文介绍了如何覆盖日期选择器的高度和宽度以填充父布局的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个活动包含日期选择器。我想将 DatePicker
设置为适合屏幕大小。我尝试了
我要在绿色区域上填充日期选择器
解决方案
尝试这个..
<?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>
< DatePicker
android:layout_width = wrap_content
android:layout_height = match_parent
android:layout_gravity = center
android: layout_marginTop = 37dp
android:layout_alignParentTop = true
android:layout_centerHorizontal = true
android:scaleX = 1.1
android:scaleY = 1.1 / >
< / RelativeLayout>
这样的输出。
< a href = https://i.stack.imgur.com/ov1bw.png rel = nofollow noreferrer>
I have an activity contains a date picker. I want to set DatePicker
fit to the screen. I tried this answer. But which not able to give the result i need.
This is my current code:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<DatePicker
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</LinearLayout>
This is my DatePicker
:
I want to make the date picker fill on that green square too.
解决方案
try this ..
<?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" >
<DatePicker
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_marginTop="37dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:scaleX="1.1"
android:scaleY="1.1"/>
</RelativeLayout>
output like this..
这篇关于如何覆盖日期选择器的高度和宽度以填充父布局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文