2016-04-28 20 views
-1

編集:申し訳ありませんが、私の実装では問題がありました。レイアウトの重さが1になっていないため、問題が発生していませんでした。 layoutWeightを修正した後に動作しました。Android:textViewの中にテキストが配置されていませんか?

私は理由を知りませんが、この中にテキストを配置することができませんcustom TextView、助けてもらえますか?私は様々なことを試みましたが、何も動いていません。私のIconTextViewの中にあるアイコンは、中心にはなく、より近くにあります。ありがとう!!

<LinearLayout 
      android:layout_width="0dp" 
      android:layout_height="match_parent" 
      android:layout_weight="0.25"> 

      <com.malinskiy.materialicons.widget.IconTextView 
        xmlns:app="http://schemas.android.com/apk/res-auto" 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:background="@drawable/ripple_effect" 
        android:gravity="center" 
        android:text="{zmdi-play}" 
        android:textColor="#ffffff" 
        android:textSize="40dp" 
        app:hacky_preview="true" /> 
    </LinearLayout> 
+0

スクリーンショットを共有します。 –

答えて

0

それは適切な解決策ではないですが、多分問題はIconTextViewの実装にあるので、あなたがIconTextViewを設定してみてください可能性が

0

あなたIconTextView要素に

android:textAlignment="gravity" 

を追加しようwrap_contentにして、IconTextView全体を折り返しLinearLayoutの内側に配置します。このような何か:

<LinearLayout 
    android:layout_width="0dp" 
    android:layout_height="match_parent" 
    android:layout_weight="0.25" 
    android:gravity="center"> 

    <com.malinskiy.materialicons.widget.IconTextView 
      xmlns:app="http://schemas.android.com/apk/res-auto" 
      android:layout_width="wrap_content" 
      android:layout_height="match_parent" 
      android:background="@drawable/ripple_effect" 
      android:text="{zmdi-play}" 
      android:textColor="#ffffff" 
      android:textSize="40dp" 
      app:hacky_preview="true" /> 
</LinearLayout> 
0

あなたはコード

<RelativeLayout 
android:layout_width="match_parent" 
android:layout_height="wrap_content" 
> 

<com.malinskiy.materialicons.widget.IconTextView 
     xmlns:app="http://schemas.android.com/apk/res-auto" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_centerInParent="true" 
     android:background="@drawable/ripple_effect" 
     android:text="{zmdi-play}" 
     android:textColor="#ffffff" 
     android:textSize="40dp" 
     app:hacky_preview="true" /> 
</RelativeLayout> 

希望の下のような相対的な相対的なレイアウトでテキストビューを使用することができ、これはあなたが

+0

これはできません、私はレイアウトウェイトを使用しています – varunkr

+0

リニアレイアウト内に相対レイアウトを追加し、リニアレイアウトにウェイトを割り当てることができます。 – sukhbir

0
<LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"> 

     <com.malinskiy.materialicons.widget.IconTextView 
       xmlns:app="http://schemas.android.com/apk/res-auto" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:background="@drawable/ripple_effect" 
       android:gravity="center" 
       android:text="{zmdi-play}" 
       android:textColor="#ffffff" 
       android:textSize="40dp" 
       app:hacky_preview="true" /> 
</LinearLayout> 

これを試してみてくださいするのに役立ちます。..あなたを助けるかもしれない..

+0

ありがとう、編集をご覧ください。 – varunkr

関連する問題