简体   繁体   中英

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)

在此处输入图片说明

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 should fill the entire screen. 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. Check this library for this, it's pretty easy: https://github.com/cymcsg/UltimateRecyclerView

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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