The problem with feeding to the Nexus 7 tablet

I notice some padding problems on a Nexus 7 tablet running Android 4.1. In particular, I have a background image with an addition that creates an external move:

<?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" > <stroke android:width="1dp" android:color="#59000000" /> <padding android:bottom="1dp" android:left="1dp" android:right="1dp" android:top="1dp" /> </shape> 

This is complemented by an internal 1dp white beat. So it should be a 2 dp square border around the whole image:

I tested it on the mobile device itself and on several other devices and a 7-inch bean emulator:

Firstly, here is the working version from the 4.1-inch emulator: This is the 7 inch tablet emulator for 4.1

The border around the outside is flat and goes around the whole image. Here's how it works on all the other devices that I have.

Nexus 7:

Image with messed up padding

The background color is gray, but you can see that the right and bottom fill are not respected. Now the border is closed by the image.

If that matters, these are the children of the GridView. I wonder if anyone saw these problems or ideas on how to solve them.

+7
source share
1 answer

This seems like a mistake when creating a stroke in an XML drawing. After several attempts, I narrowed it down to this; It seems to make the wrong stroke size on the bottom and right sides of the form, even if specified in pixels. If I just change the stroke width to 2dip instead of 1dip (everything else remains as it is), this is the result:

enter image description here

This is the border.xml that I used for the background after the image:

 <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <stroke android:width="2dp" android:color="#59000000"/> <padding android:bottom="1dp" android:left="1dp" android:right="1dp" android:top="1dp"/> </shape> 

Which, again, is only yours, with an increased stroke width. Well, this does not change the expected result at all , since the indentation remains unchanged. In fact, you can change the stroke tag to solid and still have the same result (however, if your images contain transparency, you will see a solid background in transparent areas).

Try it; let me know how it works for you!

+2
source

All Articles