How can I use layout_width using resource file?

Shakra picture Shakra · Jul 28, 2011 · Viewed 10.3k times · Source

There are a activity what I want to fill the screen in a phone and pop up(dialog) for a tablet.

I thought I make a layout file like this,

<LinearLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  android:orientation="vertical"
  android:layout_width="@dimen/main_layout_width"
  android:layout_height="match_parent">

and externalize the value of width as

in values/dimens.xml

<dimen name="tutorial_width">match_parent</dimen>

in values-xlarge/dimens.xml

<dimen name="tutorial_width">320dp</dimen>

But I can't representation 'match_parent' as dimen element. Any help? Thanks!

Answer

pjanecze picture pjanecze · Mar 9, 2012

The best way I found: - instead of "match_parent" and "fill_parent" write "-1dp" - instead of "wrap_content" write "-2dp"