Eclipse Android Layout: Without dp-values? -


if want have picture in center of layout, use: "center vertically" , "center horizontally". want picture have in center of left side. don't want use marginleft=..dp. want work without dp. there possibility "center vertically" etc? here code dp-values. can use instead of marginleft"38dp"?

 <?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android"     android:layout_width="match_parent"     android:layout_height="match_parent" >         <imageview     android:id="@+id/imageview1"     android:layout_width="150dp"     android:layout_height="150dp"     android:layout_centerinparent="true"     android:layout_marginleft="41dp"     android:src="@drawable/rosezwei" />  </relativelayout> 

if understood correctly want image center @ 25% of screen width...
alas android has no percentage in xml, must use linearlayout split screen

<linearlayout    android:layout_width="match_parent"    android:layout_height="wrap_content"    android:orientation="horizontal">    <imageview       android:id="@+id/imageview1"       android:layout_width="0dp"       android:layout_height="wrap_content"       android:layout_weight=".5"       android:layout_gravity="center"       android:src="@drawable/rosezwei" />    <space       android:layout_width="0dp"       android:layout_height="wrap_content"       android:layout_weight=".5"/> </linearlayout> 

Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

Kivy: Swiping (Carousel & ScreenManager) -