0

I want to set Logo before the app name in activities? Please anyone help me to set logo(icon) in activity page in top right corner..

Helina D
  • 3
  • 3
  • See http://stackoverflow.com/a/7316822/687315 – quietmint Dec 24 '12 at 07:14
  • You have to go with custom title bar. check below link http://stackoverflow.com/questions/3438276/change-title-bar-text-in-android – Nirav Ranpara Dec 24 '12 at 07:14
  • @NiravRanpara This would only be required in older versions of Android that do not support the ActionBar, and only if you chose not to use the support library for those older versions. – quietmint Dec 24 '12 at 07:16
  • @Helina Deveraj, Please add your research and tries so that we know what was exact problem, You cannot ask people to write codes for you. – Rais Alam Dec 24 '12 at 07:32

1 Answers1

1

CustomWindowTitle.xml

public class CustomWindowTitle extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);

        setContentView(R.layout.main);

        getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.window_title);
    }
}

window_title.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="35dip"
    android:gravity="center_vertical"
    android:paddingLeft="5dip"
    android:background="#323331">

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

</LinearLayout>

Download Demo

Nirav Ranpara
  • 13,753
  • 3
  • 39
  • 54
  • 1
    I would definitely recommend using the native [ActionBar](http://developer.android.com/guide/topics/ui/actionbar.html)'s logo capabilities over rolling your own. – quietmint Dec 24 '12 at 07:19