1

私はlistViewの上にカスタムタイトルを付けたいと思います。 threadsを読んだ後、私は次のようにコードを作ったが、タイトルバーのサイズは非常に小さくなっていて、少し大きめにしたい。また、scrolling downリストの間には、大きな隙間がlistviewのトップバーとタイトルバーの間に作成されます。どうすればこれを避けることができますか?誰か助けてくれますか?リストビューでの私のカスタムタイトルに適切な高さとフォーマットが表示されない

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.citylisttitle); 
    } 

答えて

3

ここで私はそれをしました。 まず、マニフェストであなたの活動にタイトルがないことを設定します。

<activity android:name="Detail" 
    android:label="@string/app_name" 
    android:theme="@android:style/Theme.Light.NoTitleBar"/> 

レイアウトの上部にカスタムタイトルバーを追加します。

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"> 

    <LinearLayout android:id="@+id/detail_titleBar" 
    android:orientation="vertical" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:background="@android:drawable/title_bar" 
    android:layout_alignParentTop="true"> 

     <TextView android:id="@+id/detail_account" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_gravity="center_horizontal" 
     android:paddingTop="5dp" 
     android:paddingBottom="5dp" 
     android:textSize="18sp" 
     android:textColor="@android:color/white"/> 

    </LinearLayout> 

    <ListView android:id="@+id/detail_list" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:layout_below="@id/detail_titleBar" 
    android:layout_above="@+id/detail_iconbar"/> 

<LinearLayout android:id="@+id/detail_iconbar" 
    android:orientation="horizontal" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_alignParentBottom="true" 
    android:background="@android:drawable/bottom_bar" 
    android:gravity="center_vertical"> 
    .... 
+0

ありがとう。素晴らしい解決策。 –

+0

これは簡単な解決策です –