2012-12-24 29 views
0

我想在活动中的应用程序名称之前设置Logo? 请人帮我设置在右上角活动页面标志(图标)..Android:如何在Android应用程序的所有活动中设置标志

+0

请访问http ://stackoverflow.com/a/7316822/687315 – user113215

+0

你必须去自定义标题栏。下面检查链接 http://stackoverflow.com/questions/3438276/change-title-bar-text-in-android –

+0

@NiravRanpara这只会在旧版本的Android不支持的ActionBar需要,并且只有在您选择不使用旧版本的支持库时才适用。 – user113215

回答

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

+1

我肯定会推荐使用原生[ActionBar](http://developer.android.com/guide/topics/ui/actionbar.html)的标志功能来滚动你自己的。 – user113215

相关问题