0

私は単純なレイアウトを持っています:

    <?xml version="1.0" encoding="utf-8"?>
   <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_gravity="center_vertical|center_horizontal"
    android:orientation="horizontal" >
   <fragment class="my.test.package.CitiesFragment"
      android:id="@+id/cities" android:layout_weight="4" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content"      
      android:layout_gravity="center_vertical|center_horizontal"
      />
  //....
   </LinearLayout>

左側に、都市を入力したリストフラグメントがあることがわかります。Listfragment は、単純なカスタム アダプターで構成されます。

setListAdapter(new CitiesArrayAdapter<String>(getActivity(), R.layout.city_list_item, citiesArrayList));

そしてcity_list_item.xmlは次のとおりです。

<my.test.package.VerticalTextView xmlns:android="http://schemas.android.com/apk/res/android"
        style="@style/verticalTextStyle"
        android:id="@+id/VerticalTextView" android:layout_width="fill_parent"
    android:layout_height="fill_parent"         
    android:gravity="center_horizontal|center_vertical"
    android:layout_gravity="center_horizontal|center_vertical"          
    android:background="@android:color/black"
    android:textColor="@android:color/white"
        />

VerticalTextView クラスは、この Web サイトから取得されました。コードはここにあります: VerticalTextView クラス

これは私がこれまでに持っているものです: ここに画像の説明を入力

写真からわかるように、都市は左揃えになっています。どうすればそれらの都市を中心に置くことができますか??? これは私を夢中にさせています!

***** 問題が見つかりました: verticaltextview クラスにあります: canvas.translate( getCompoundPaddingLeft(), getExtendedPaddingTop() );**

getCompoundPaddingLeft right top bottom は常に 30 を返し、レイアウトがめちゃくちゃになります。誰もが理由を知っていますか?????????? または修正方法??

4

0 に答える 0