Views with the same dip width number have different widths in appearance on device

by Michael Smith » Thu, 27 Jan 2011 12:32:04 GMT


Sponsored Links
 I have a horizontal linear layout separated with lines like the
following:

    <View
      android:background="@drawable/gradient_white2"
      android:layout_height="fill_parent"
      android:layout_width="1dip"
    />

In the layout editor, the lines have the same width, however, on the
device they do not - the second line in the layout below is slightly
wider than the other two. I'm wondering if there is an explanation for
this or a way around it.

Here is what the layout looks like:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android=" http://schemas.android.com/apk/res/ 
android"
  android:background="@drawable/customized_title_bar_button"
  android:layout_height="fill_parent"
  android:layout_width="fill_parent"
  android:orientation="horizontal"
  <ImageButton
    android:background="@drawable/customized_title_bar_button"
    android:id="@+id/home"
    android:layout_height="fill_parent"
    android:layout_width="wrap_content"
    android:src="@drawable/header_logo_small"
  />
  <LinearLayout
    android:background="@drawable/gradient_shape_blue"
    android:gravity="right|center"
    android:layout_weight="1"
    android:layout_height="fill_parent"
    android:layout_width="wrap_content"
    android:orientation="horizontal"
  >
    <View
      android:background="@drawable/gradient_white2"
      android:layout_height="fill_parent"
      android:layout_width="1dip"
    />
    <ImageButton
      android:background="@drawable/customized_title_bar_button"
      android:id="@+id/map"
      android:layout_height="fill_parent"
      android:layout_width="wrap_content"
      android:src="@drawable/globe_icon"
    />
    <View
      android:background="@drawable/gradient_white2"
      android:layout_height="fill_parent"
      android:layout_width="1dip"
    />
    <ImageButton
      android:background="@drawable/customized_title_bar_button"
      android:id="@+id/saved"
      android:layout_height="fill_parent"
      android:layout_width="wrap_content"
      android:src="@drawable/saved_icon"
    />
    <View
      android:background="@drawable/gradient_white2"
      android:layout_height="fill_parent"
      android:layout_width="1dip"
    />
    <ImageButton
      android:background="@drawable/customized_title_bar_button"
      android:id="@+id/search"
      android:layout_height="fill_parent"
      android:layout_width="wrap_content"
      android:src="@drawable/search_icon"
    />
  </LinearLayout>
</LinearLayout>

Thanks,

Mike

-- 



Views with the same dip width number have different widths in appearance on device

by Michael Smith » Thu, 27 Jan 2011 12:32:04 GMT


 I have a horizontal linear layout separated with lines like the following:

 *   <View*
*      android:background="@drawable/gradient_white2"*
*      android:layout_height="fill_parent"*
*      android:layout_width="1dip"*
*    />*

In the layout editor, the lines have the same width, however, on the device
they do not - the second line in the layout below is slightly wider than the
other two. I'm wondering if there is an explanation for this or a way around
it.

Here is what the layout looks like:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android=" http://schemas.android.com/apk/res/android" ;
  android:background="@drawable/customized_title_bar_button"
  android:layout_height="fill_parent"
  android:layout_width="fill_parent"
  android:orientation="horizontal"
  <ImageButton
    android:background="@drawable/customized_title_bar_button"
    android:id="@+id/home"
    android:layout_height="fill_parent"
    android:layout_width="wrap_content"
    android:src="@drawable/header_logo_small"
  />
  <LinearLayout
    android:background="@drawable/gradient_shape_blue"
    android:gravity="right|center"
    android:layout_weight="1"
    android:layout_height="fill_parent"
    android:layout_width="wrap_content"
    android:orientation="horizontal"
  >
*    <View*
*      android:background="@drawable/gradient_white2"*
*      android:layout_height="fill_parent"*
*      android:layout_width="1dip"*
*    />*
    <ImageButton
      android:background="@drawable/customized_title_bar_button"
      android:id="@+id/map"
      android:layout_height="fill_parent"
      android:layout_width="wrap_content"
      android:src="@drawable/globe_icon"
    />
 *   <View*
*      android:background="@drawable/gradient_white2"*
*      android:layout_height="fill_parent"*
*      android:layout_width="1dip"*
*    />*
    <ImageButton
      android:background="@drawable/customized_title_bar_button"
      android:id="@+id/saved"
      android:layout_height="fill_parent"
      android:layout_width="wrap_content"
      android:src="@drawable/saved_icon"
    />
 *   <View*
*      android:background="@drawable/gradient_white2"*
*      android:layout_height="fill_parent"*
*      android:layout_width="1dip"*
*    />*
    <ImageButton
      android:background="@drawable/customized_title_bar_button"
      android:id="@+id/search"
      android:layout_height="fill_parent"
      android:layout_width="wrap_content"
      android:src="@drawable/search_icon"
    />
  </LinearLayout>
</LinearLayout>

Thanks,

Mike

-- 


Sponsored Links


Other Threads

1. android-x86 test build 20091113 is available

The Android-x86 project is glad to announce a new test build
20091113 for public testing. A live cd ISO and USB image are
available from our site:

 http://www.android-x86.org/download
 http://code.google.com/p/android-x86/downloads/list

Features

Build 20091113 is Android 1.6 (Donut) based and it is a release
candidate for android-x86 1.6 stable release.
In addition to the features available in previous release, the new
build contains

 * Hardware OpenGL support from olv in 0xlab.
 * Fn key support for EeePC platforms.
 * External USB bluetooth support.
 * NDK for X86 platforms is supported (based on the original work
from guillaume.etiev...@laposte.net)
 * new touch features to simulate home/menu/back keys to support
touch only device.
 * Improvement on the keyboard support. User can use ctrl+c directly
from terminal simulator now.
 * A lots of bug fixes.

Released Files

 * Live CD iso: android-x86-20091113.iso

  sha1sum: dec0b99a6fe1e33e05b665e82f3020f612eb14bf

 * Live USB image: android-x86-20091113_usb.img.gz

  sha1sum: ce040ced2da92c278c7df2527b5f3498a68afbfa

Source code

The source code is available in our git server:

 $ repo init -u git://git.android-x86.org/android-x86/platform/manifest.git
 $ repo sync

Test reports (success or fail) are welcome.
Please send the reports to the Android-x86 discussion group.

2. Does MotionEvent.getEdgeFlags() ever return anything other than 0 ?

I was expecting the getEdgeFlags() method of MotionEvent to tell me
when a MotionEvent had reached the edge of something, but the value
returned from getEdgeFlags() is *always* zero. Is this the expected
behavior? The documentation says that the flags indicate when a touch
has reached the edge of the display. I've tried this on a real device
and in the emulator, and the location coordinates never quite reach
the edge of the display, and getEdgeFlags() always returns 0. By
"never quite reach" I mean that if dragging a finger off the left edge
of the display, the smallest X I got was 2. Reaching the edge of the
view doesn't seem to change the value returned either.

I suppose I could set the flags myself using setEdgeFlags() using
calculations with known dimensions of the object whose edges I care
about. Is that how it's supposed to be used? Is this broken for now?

Thanks for your help.

- dave

-- 

3. A request for people creating custom Android systems

4. installing Android 1.6+ on headless Linux server

5. Can't we have multiple instances for root of a task, in the same task?

6. write to cursor?

7. Android 2.0 on HTC Magic