0

DialogBuilderで作成されていますが、Axmlファイルの内容をビューとして膨張させます。私は入れ子になった2レベルのシステムLinearLayoutsを持っています。これらのコンテンツの1つにTextViewと若干縮小されたTimePickerが含まれています。ここでは、対応するAXMLの関連する部分である:Xamarin C#:中心にあるAxML要素の垂直方向の内側LinearLayout

<LinearLayout 
     android:orientation="horizontal" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content"> 
     <TextView 
      android:text="Start" 
      android:textAppearance="?android:attr/textAppearanceMedium" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:id="@+id/textView2" 
      android:gravity="center_vertical"/> 
     <TimePicker 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:scaleX="0.80" 
      android:scaleY="0.80" 
      android:timePickerMode="spinner" 
      android:id="@+id/endPicker" /> 
    </LinearLayout> 

そして、これが(AM/PMが私mothertongueである)、それはスマートフォンでどのように見えるかです:

enter image description here

テキストSTARTを指し、時間の期間の開始まで、私は(手動で変更PIC OCである)このような時ピッカー何かの中央に垂直に揃えたい:

enter image description here

しかし何らかの理由で、私はテキストをどのように整列させても、それを行うことはできません。私は既にTableViewを試してみましたが、HEREと似ていますが、助けにはなりませんでした。私はまた、両方の要素のマージンを試してみましたが、ピッカーが目立たないように "パッディング"されていた場合、テキストはまだcenter_verticalに設定されています。 TimePickerに属するいくつかの隠し要素がここに非難されると仮定しますが、私は何をどのように把握できません。私がここに来ていないのは何ですか?

答えて

1

は単に「センター」

に「center_vertical」からのTextViewに重力フィールドを変更してみてください編集:追加のコード

<LinearLayout 
    android:orientation="horizontal" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content"> 
    <TextView 
     android:text="Large Text" 
     android:textAppearance="?android:attr/textAppearanceMedium" 
     android:layout_width="wrap_content" 
     android:layout_height="match_parent" 
     android:id="@+id/textView1" 
     android:gravity="center" /> 
    <TimePicker 
     android:layout_width="wrap_content" 
     android:layout_height="match_parent" 
     android:id="@+id/timePicker1" /> 
</LinearLayout> 
+0

は残念ながら、これはまったく同じ結果になります。ピッカーに50〜60ほどの左パディングを与えても、一見テキスト(?)にはスペースがたくさんありますが、それを占有しません。 – rTECH

+0

layout_widthプロパティとlayout_heightプロパティを変更したことを忘れてしまった。それらも変更しましたか?重要なのは、テキストビューのlayout_heightがparentと一致していることです。 –

+1

ありがとう!私はそれを逃した、それはトリックをした! – rTECH

関連する問題