Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Overwriting paddingLeft in a LinearLayout on Android

Tags:

java

android

i am currently making one android application, i moded title bar, so all content for title bar is holded in window_title.xml where i have LinearLayout set: paddingLeft="5dip" . And now i need to load one imageView on the right side of this titleBar how i am able to some kind of overwrite this paddingLeft i cant delete it as it required for text and image on the left but i need it on right too...

Here is current xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="horizontal"
    android:layout_width="fill_parent"
    android:layout_height="50dip"
    android:gravity="center_vertical"
    android:paddingLeft="5dip"
    android:background="#222222">

    <ImageView
        android:id="@+id/header"
        android:src="@drawable/header"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"/>    

    <TextView         
        android:text="TextTexast"
        android:textSize="10pt"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:paddingLeft="5dip"
        android:textColor="#F7F7F7"
        />

</LinearLayout>
like image 256
HyperX Avatar asked Dec 01 '25 17:12

HyperX


1 Answers

If I understand your question correctly, you're looking to apply some padding to an ImageView that you display to the right of the titlebar TextView. You can use android:paddingRight in your root LinearLayout like this:

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="horizontal"
    android:layout_width="fill_parent"
    android:layout_height="50dip"
    android:gravity="center_vertical"
    android:paddingLeft="5dip"
    android:paddingRight="5dip
    android:background="#222222">

Alternatively, you can specify the android:paddingRight attribute in the ImageView that you want to align to the right.

like image 109
Code Poet Avatar answered Dec 03 '25 07:12

Code Poet



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!