ライブラリ互換性を使用してGridLayoutを使用する際に問題があります。 android:layout_gravity="fill_horizontal"
の代わりにapp:layout_gravity="fill_horizontal"
を使用していますが、TextView
内のすべてのコンテンツは表示されません。すべてを表示するには、TextView
「タイトル」の高さを設定する必要がありますが、高さを設定するのではなく、動的な高さが必要です。GridLayout内のTextViewの動的な高さ
答えて
TextViewにはlayout_width="0dp"
とlayout_gravity="fill_horizontal"
を設定する必要があります。
<TextView
android:layout_width="0dp"
app:layout_gravity="fill_horizontal" />
してください、ここでは完全な例を参照してください。https://groups.google.com/d/msg/android-developers/OmH3VBwesOQ/ZOGR0SGvC3cJかここに:GridLayout
内部TextView
を使用してhttp://daniel-codes.blogspot.com/2012/01/gridlayout-view-clipping-issues.html
には問題があるが、は一緒に両方を使用するための良い方法あります。
これは、例えばレイアウトは次のようになります。
そして、これは完全なレイアウトxmlです、重要な行は***でマークされています。
<?xml version="1.0" encoding="utf-8"?>
<GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:columnCount="3" * this example uses 3 columns
android:orientation="horizontal" > *** use "horizontal"
<TextView * just a normal view
android:layout_column="0"
android:layout_row="0"
android:background="#666666"
android:text="A"
android:textColor="#afafaf"
android:textSize="60sp"
android:textStyle="bold" />
<TextView * this text will not be cut!
android:layout_width="0dp" *** important: set width to 0dp
android:layout_height="wrap_content"
android:layout_column="1"
android:layout_columnSpan="2" * colspan does also work with this
android:layout_gravity="fill_horizontal|bottom" *** set to "fill*"!
android:layout_row="0"
android:text="This view has 2 columns. Lorem ipsum dolor sit amet, consetetur sadipscing elitr."
android:textColor="#666666" />
</GridLayout>
必要に応じて、またこの組み合わせは動作します:あなたが仕事に、このためにandroid
以外の任意の名前空間を使用する必要はありません
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_gravity="fill"
android:gravity="bottom"
注意を。
ありがとう、それは動作します。しかし、私はあなたがそのトリックをどのように発見したのか不思議です。 (0dpの 'layout_width'と' layout_gravity'のためのfillプロパティ) – Leo
素晴らしい仕事が見つかりました。私のTextLayoutが私のGridLayoutの中にテキストを正しくラッピングするのは苦労しました。この同じ問題に関する多くのトピックに関する他のすべての提案と回答に続きましたが、自分だけが働いていました。どうもありがとうございました! :) –
- 1. AndroidのTextViewの幅と高さを動的に設定する
- 2. 動的な高さのdiv
- 3. iframeの動的な高さ
- 4. OHAttributedLabelの動的な高さ
- 5. UIScrollViewの動的な高さ
- 6. カスタムセル内のUILabelは、高さを動的に増やさない
- 7. 相対的なレイアウトの動的TextView
- 8. HTMLテーブル内の行の動的な高さ
- 9. TextViewの高さを取得
- 10. GridlayoutのTextViewが画面外に表示される
- 11. androidのListView行の動的な高さ
- 12. iframeの動的な高さの調整
- 13. 動的な高さが同じ高さの2つのdivs
- 14. ニットプロットの動的な高さと幅
- 15. jQuery - 動的なdivの高さ
- 16. クローンオブジェクトの動的な高さを取得
- 17. 動的なdivの高さを固定
- 18. iPhone - >動的なセルの高さ
- 19. 動的iframeの高さ
- 20. 動的行の高さ
- 21. 動的セルの高さiOS
- 22. 動的高さUITableViewCell
- 23. Androidのtextviewの高さとチェックボックスのリストビュー
- 24. セル内のコンテンツの高さを無視して動的なテーブルの行の高さ
- 25. 動的な高さを持つUITableViewCell、UITextView
- 26. iOS 6の自動レイアウトで動的なUIViewの高さ
- 27. ベースdivの高さ(動的キャンバスの高さ)
- 28. 変更相対的なレイアウトの幅と高さを動的
- 29. QTextEditのような高さを自動的に内容にラップするQWidget?
- 30. テーブルの動的行の高さ
** app:** layout_gravityに注意することが重要です。私はスタイルの価値を設定していたとリントは私に警告していない、問題を把握するために私をしばらくかかった。 – basilisk
2行目にある場合は、前の行の幅の幅をとります –