简体   繁体   English

如何使UI元素充满整个Android屏幕

[英]How do I make UI elements fill the entire Android Screen

I am trying to add a bar similar to the "Today" bar here, but I cannot figure out how to force the width to match the screen. 我试图在此处添加类似于“今日”栏的栏,但是我无法弄清楚如何强制宽度匹配屏幕。 I am just using a simple textview (if there is a better way.. that's awesome, please tell it to me, but i cant find anything for it) 我只是用一个简单的textview(如果有更好的方法..太好了,请告诉我,但是我找不到任何东西)

在此处输入图片说明

Here is what is happening with match_parent or fill_parent I recolored the textview to show the margins (that I dont want) 这是match_parent或fill_parent发生的事情,我为textview重新着色以显示边距(我不想要)

在此处输入图片说明

match_parent should fill the entire screen. match_parent应该填满整个屏幕。 Check your parent activity layout or your fragment layout and you should find your margins there. 检查您的父活动布局或片段布局,您应该在此处找到边距。

BTW, if you have a list of items like the one in the picture and you want it to have sections (like 'today', 'yesterday', etc) you should probably use recyclerview with headers instead of text view. 顺便说一句,如果您有一个项目列表,如图片中的项目列表,并且希望它具有某些部分(例如“ today”,“ yesterday”等),则应该使用带有标题的recyclerview而不是文本视图。 Check this library for this, it's pretty easy: https://github.com/cymcsg/UltimateRecyclerView 检查此库,这非常简单: https : //github.com/cymcsg/UltimateRecyclerView

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

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