Hi guys I want to have an image that I got from the Vector Asset tab to filled the entire screen on my GridView items. Currently, it looks like this at the moment . I want to have all my TextViews and ImageView to be inside of this if possible.
Here is the necessary code
This is the XML layout that my GridView currently adapts and inflate with. Look at the top part of the code to save time to see the --> android:background="@drawable/ic_folder_white_24dp">
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
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:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/ic_folder_white_24dp">
<!-- android:background="@drawable/text_view_border">-->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<CheckBox
android:id="@+id/check_box"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone"/>
<TextView
android:id="@+id/date_created"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@color/black"
android:textSize="15sp"
android:gravity="center" />
</LinearLayout>
<TextView
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="25sp"
android:textColor="@color/black"
android:gravity="center"/>
<TextView
android:id="@+id/desc"
android:layout_width="match_parent"
android:padding="8dp"
android:textColor="@color/black"
android:layout_height="250dp" />
<ImageView
android:id="@+id/psw_lock"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_lock_black_24dp"
android:layout_gravity="end"
android:paddingBottom="5dp"
android:paddingRight="5dp"
android:visibility="invisible"
/>
</LinearLayout>
Here is my GridView code in my mainActivity.xml though I don't think its revelant
<GridView
android:id="@+id/grid_view"
android:layout_below="@+id/toolbar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="12dp"
android:verticalSpacing="5dp"
android:horizontalSpacing="5dp"
android:numColumns="2">
</GridView>
Lastly here is my drawable image itself. I try messing with the values though nothing points to the right direction. By default it got me 24dp.
<vector android:height="24dp" android:tint="#FFDF00"
android:viewportHeight="24.0" android:viewportWidth="24.0"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FF000000" android:pathData="M10,4H4c-1.1,0 -1.99,0.9 -1.99,2L2,18c0,1.1 0.9,2 2,2h16c1.1,0 2,-0.9 2,-2V8c0,-1.1 -0.9,-2 -2,-2h-8l-2,-2z"/>
</vector>
Any help would be appreciative.
If you mean you want a folder on each grid item, with all the other views inside it, you'll need to set some padding on the item's layout or margins on its views, so they don't overlap the edges. Whatever works to fit the image!
If you mean you want one big folder as the entire background, you'll need to set that as the background to the GridView
area in your activity's layout file. So it's the background of the whole grid container, not separate backgrounds for each item.
Also I don't think you can avoid the background being stretched to fit the view, so you'll probably need to add an ImageView
with scaleType="fitCenter"
or something (and you won't be able to use a LinearLayout
to overlay something on that image)
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.