I am running the app on Galaxy Note, which is hdpi. And I got all the drawables (drawable-hdpi, drawable-mdpi etc.) correct. But the page (activity) is weirdly zoomed in like this:
You can notice that the cursor icon, top header and the background tiles are larger than normal.
It is supposed to be like this:
The layout file:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="#drawable/bg_app"
>
<EditText android:id="#+id/content"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:inputType="textMultiLine|textCapSentences"
android:textColor="#000"
android:textSize="18sp"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:gravity="top|left"
android:padding="10dp"
android:layout_margin="10dp"
android:lineSpacingMultiplier="1.1"
android:minLines="3"
/>
</LinearLayout>
you need to add the following to the manifest
the tag "uses-sdk" with android:minSdkVersion="8" (it might work with 7 I did not test)
:-)
Problem solved by using
<uses-sdk android:minSdkVersion="4" />
in AndroidManifest.xml
Related
I am developing an Android app running on Xperia Z and Xperia tablet Z.
My problem is that Gravity.RIGHT property is taking effect when anyDensity=true in the AndroidManifest, but it does not work when anyDensity=false. Some rightmost characters are partly hidden as shown below.
I tried various settings changes in TextView and Layout, but have failed to display them all. Could someone advise me what I should set to make Gravity.RIGHT completely work when anyDensity=false?
Thank you.
`
----------------------------------------
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#000000"
>
<TextView
android:id="#+id/textDP"
android:textStyle="bold"
android:typeface="normal"
android:textSize="15.125dp"
android:textColor="#0000ff"
android:background="#cccccc"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:gravity="center_vertical|right"
android:layout_marginLeft="50px"
android:layout_marginTop="50px"
android:text="#string/Sample001"
/>
<TextView
android:id="#+id/textDP"
android:textStyle="bold"
android:typeface="normal"
android:textSize="15.125dp"
android:textColor="#0000ff"
android:background="#cccccc"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:gravity="center_vertical|right"
android:layout_marginLeft="50px"
android:layout_marginTop="75px"
android:text="#string/Sample002"
/>
: #Omission
----------------------------------------
`
If you use android:anyDensity="false". This causes you to go into old density compatibility mode, which you do not want. Instead of setting your text size / layout widths ect. with pt use the density independent dp. cheers
As I posted here how-can-i-create-layout-for-both-320dp-and-360dp. In that question I gave a simple example about two buttons. But Now I've my layout for 320dp and I couldn't create a layout for 360dp like Motorola Atrix. Because the solution was given was related for LinearLayout and my layout now is Relative. How can I avoid or fill the blank space at right?
layout.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="#drawable/bg_tapfast" >
<ImageView
android:id="#+id/img_logomaior"
android:layout_width="#dimen/default_width_img_logomaior"
android:layout_height="#dimen/default_height_img_logomaior"
android:src="#drawable/img_logomaior"
android:layout_marginTop="#dimen/margin_top_img_logomaior"
android:layout_marginLeft="#dimen/margin_left_img_logomaior"
android:layout_alignParentLeft="true" />
<ImageView
android:id="#+id/img_mode_tapcolor"
android:layout_width="#dimen/default_width_mode_tapcolor"
android:layout_height="#dimen/default_height_mode_tapcolor"
android:src="#drawable/mode_tapcolor"
android:layout_marginTop="#dimen/margin_top_mode_tapcolor"
android:layout_marginLeft="#dimen/margin_left_mode_tapcolor" />
<ImageView
android:id="#+id/img_mode_tapname"
android:layout_width="#dimen/default_width_mode_tapname"
android:layout_height="#dimen/default_height_mode_tapname"
android:src="#drawable/mode_tapname"
android:layout_marginTop="#dimen/margin_top_mode_tapname"
android:layout_marginLeft="#dimen/margin_left_mode_tapname" />
<ImageView
android:id="#+id/img_mode_tapgroup"
android:layout_width="#dimen/default_width_mode_tapgroup"
android:layout_height="#dimen/default_height_mode_tapgroup"
android:src="#drawable/mode_tapgroup"
android:layout_marginTop="#dimen/margin_top_mode_tapgroup"
android:layout_marginLeft="#dimen/margin_left_mode_tapgroup" />
<ImageView
android:id="#+id/img_tap_2be"
android:layout_width="#dimen/default_width_tap_2be"
android:layout_height="#dimen/default_width_tap_2be"
android:src="#drawable/tap_2be"
android:layout_alignParentBottom="true"
android:layout_marginLeft="#dimen/margin_left_tap_2be" />
<ImageView
android:id="#+id/img_bt_howtoplay"
android:layout_width="#dimen/default_width_bt_howtoplay"
android:layout_height="#dimen/default_height_bt_howtoplay"
android:src="#drawable/bt_howtoplay"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true" />
</RelativeLayout>
Motorola Atrix
Samsung Galaxy SII
This might help you
http://developer.android.com/resources/articles/layout-tricks-efficiency.html
and this one http://developer.android.com/resources/articles/layout-tricks-merge.html
You'll have to post your code for me to be sure.
But you should be able to add an attribute like this to your RelativeLayout:
android:gravity="center_horizontal"
EDIT: I think if you put your 3 ImageViews inside of their own layout and set the gravity on the top level parent to be center horizontal it will keep all of your ImageViews in the same position relative to each other, but it will also scoot them over some so they are centered no matter which device you are running on.
something like this:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center_horizontal"
android:background="#drawable/bg_tapfast" >
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
<ImageView
android:id="#+id/img_logomaior"
android:layout_width="#dimen/default_width_img_logomaior"
android:layout_height="#dimen/default_height_img_logomaior"
android:src="#drawable/img_logomaior"
android:layout_marginTop="#dimen/margin_top_img_logomaior"
android:layout_marginLeft="#dimen/margin_left_img_logomaior"
android:layout_alignParentLeft="true" />
<ImageView
android:id="#+id/img_mode_tapcolor"
android:layout_width="#dimen/default_width_mode_tapcolor"
android:layout_height="#dimen/default_height_mode_tapcolor"
android:src="#drawable/mode_tapcolor"
android:layout_marginTop="#dimen/margin_top_mode_tapcolor"
android:layout_marginLeft="#dimen/margin_left_mode_tapcolor" />
<ImageView
android:id="#+id/img_mode_tapname"
android:layout_width="#dimen/default_width_mode_tapname"
android:layout_height="#dimen/default_height_mode_tapname"
android:src="#drawable/mode_tapname"
android:layout_marginTop="#dimen/margin_top_mode_tapname"
android:layout_marginLeft="#dimen/margin_left_mode_tapname" />
<ImageView
android:id="#+id/img_mode_tapgroup"
android:layout_width="#dimen/default_width_mode_tapgroup"
android:layout_height="#dimen/default_height_mode_tapgroup"
android:src="#drawable/mode_tapgroup"
android:layout_marginTop="#dimen/margin_top_mode_tapgroup"
android:layout_marginLeft="#dimen/margin_left_mode_tapgroup" />
<ImageView
android:id="#+id/img_tap_2be"
android:layout_width="#dimen/default_width_tap_2be"
android:layout_height="#dimen/default_width_tap_2be"
android:src="#drawable/tap_2be"
android:layout_alignParentBottom="true"
android:layout_marginLeft="#dimen/margin_left_tap_2be" />
<ImageView
android:id="#+id/img_bt_howtoplay"
android:layout_width="#dimen/default_width_bt_howtoplay"
android:layout_height="#dimen/default_height_bt_howtoplay"
android:src="#drawable/bt_howtoplay"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true" />
</RelativeLayout>
</RelativeLayout>
I Have used my all my images in drawable-hdpi folder . why cannot my layout properly outcome my emulator with different sizes. I hava faced this error according to pictures.
I have also include following code in manifest file.
<supports-screens
android:smallScreens="true"
android:normalScreens="true"
android:largeScreens="true"
android:anyDensity="false"
/>
Here android:anyDensity="false" check both false and true but could not any change, and also use Resizable: true and android:smallScreens="false" also used but could not get any change.
my all images are 96dpi resolution and main background image size 480*800 for normal screen of hdpi(WVGA800). so what is the my problem please find out and help me. Thanks in advance.
Edited:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_height="fill_parent"
android:layout_width="fill_parent" android:background="#drawable/normalbg"
android:gravity="top">
<ImageView android:id="#+id/group1" android:background="#drawable/groupone"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentRight="true" android:layout_marginRight="5dip" android:layout_marginTop="138dip"/>
<ImageView android:id="#+id/group2" android:background="#drawable/grouptwo"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentRight="true" android:layout_below="#id/group1"
android:layout_marginRight="5dip"/>
<ImageView android:id="#+id/group3" android:background="#drawable/groupthree"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentRight="true" android:layout_below="#id/group2"
android:layout_marginRight="5dip"/>
<ImageView android:id="#+id/group4" android:background="#drawable/groupfour"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentRight="true" android:layout_below="#id/group3" android:layout_marginRight="7dip"/>
<LinearLayout android:orientation="horizontal"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentBottom="true" android:baselineAligned="true">
<ImageView android:id="#+id/backToLevel" android:background="#drawable/back"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentRight="true" android:layout_below="#id/group4"
android:layout_gravity="center_horizontal" android:layout_marginLeft="116dip" android:layout_marginBottom="3dip"/>
</LinearLayout>
</RelativeLayout>
I used drawable folder all images then get the all images. I used this all layout in Relative layout rather than linear, and Make the all it properties. I skip the margin , below and above properties. First on alignparentcenter is true, then below or above the that centered image. Its work fine then the above my layout.
I assume you youse RelativeLayout to show the back button on the buttom. Like this, it may hover over the menu buttons if there isnĀ“t enough space for it.
Consider adding the back button into the menu buttons' LinearLayout.
To resize the image, consider using a 9-Patch Drawable.
When using a small gif to be used as a background tile for a layout, I have found that my buttons appear transparent which is NOT what I want and I have not set any transparency parameters either (unless the background gif is transparent?)
My XML is:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:weightSum="2"
android:background="#drawable/backgroundrepeat"
>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbars="vertical"
android:id="#+id/scrollview1"
android:layout_weight="2"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp">
<TextView
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:id="#+id/textview"
android:scrollbars="vertical"
android:textColor="#android:color/black"
/>
</ScrollView>
<Button android:text="Connect To Phidget" android:id="#+id/connect_button" android:layout_width="match_parent"
android:layout_height="wrap_content"
android:enabled="false"
android:layout_weight="0"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:background="#null"
></Button>
</LinearLayout>
And the drawable tile is:
<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:src="#drawable/original10"
android:tileMode="repeat"
/>
Can anyone help? Thanks
As per the Android developer documentation, it is quite clearly stated that using GIF images is discouraged.
While they don't elaborate on the reason - I'm assuming due to its multi-layering nature. But I've played with the GIF images and encountered unwanted errors similar to yours.
So I'd suggest you to export your GIF image to a PNG and try with that. You can use any tool like Gimp or IrfanViewer.
Ok. Than remove the tag:
android:background="#null"
That makes it transparent in the way you describe it.
add this tag in button
android:background="#android:drawable/btn_default"
I'd like to use a 1x1 size Nine-patch image from Android drawable resources.
When I'm trying to display it with <ImageView> in my layout xml file, this one is never showing up on the Android emulator device. Here's the xml code below:
<?xml version="1.0" encoding="UTF-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="10px"
>
<RelativeLayout
android:gravity="center_vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView android:id="#+id/text_label"
android:text="#string/text"
android:textSize="10pt"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<CheckBox android:id="#+id/my_checkBox"
android:layout_alignBaseline="#id/text_label"
android:layout_alignParentRight="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</RelativeLayout>
<ImageView android:paddingTop="10px"
android:paddingBottom="10px"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:src="#android:drawable/divider_horizontal_bright" />
</LinearLayout>
I tried another one with the same size and I have the same problem it's still blank.
My research on Google was irrelevant. Hope you can find what am I doing wrong here.
Thanks in advance for your help.
Lorenth
What version of the SDK are you writing for?
Take a peek at the divider_horizontal_bright.png files in the different versions :)
It's 99% transparent in 8, but like 50% transparent light grey in 4.
Or, Perhaps you meant divider_horizontal_bright_opaque?
This works for me:
<ImageView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:src="#android:drawable/divider_horizontal_dark"
android:scaleType="fitXY"
/>