我尝试像这样编码
<ImageView android:id="@+id/ivIcon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@android:drawable/ic_btn_speak_now" />
<TextView
style="@style/behindMenuItemLabel"
android:text="Item0" />
Run Code Online (Sandbox Code Playgroud)
但输出是这样的。不在同一行:(

我的整个xml代码就是这样的。
(icon) item将是一个集合,用户将单击它来继续活动。
所以我需要将它们分组在一起。
<LinearLayout style="@style/behindMenuScrollContent"
android:paddingTop="25dp" >
<TextView
style="@style/behindMenuItemTitle"
android:text="Subject" />
<TextView
style="@style/behindMenuItemLabel"
android:text="Item0" />
<TextView
style="@style/behindMenuItemLabel"
android:text="Item1" />
<TextView
style="@style/behindMenuItemLabel"
android:text="Item2" />
<TextView
style="@style/behindMenuItemLabel"
android:text="Item3" />
<TextView
style="@style/behindMenuItemLabel"
android:text="Item4" />
<TextView
style="@style/behindMenuItemLabel"
android:text="Item5" />
<TextView
style="@style/behindMenuItemTitle"
android:text="Subject2" />
<TextView
style="@style/behindMenuItemLabel"
android:text="Item6" />
<TextView
style="@style/behindMenuItemLabel"
android:text="Item7" />
<TextView
style="@style/behindMenuItemLabel"
android:text="Item8" />
<TextView
style="@style/behindMenuItemLabel"
android:text="Item9" />
<TextView
style="@style/behindMenuItemLabel"
android:text="Item10" />
<Button
android:id="@+id/behind_btn"
style="@style/behindMenuItemLabel"
android:text="BUTTON" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
更新:我不需要图标和文本之间的边距,但只需要左侧的边距!

样式.xml
<style name="behindMenuItemLabel">
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_marginLeft">20dp</item>
<item name="android:layout_marginBottom">4dp</item>
<item name="android:textSize">30sp</item>
<item name="android:textColor">#d2d2d2</item>
</style>
Run Code Online (Sandbox Code Playgroud)
尝试这样的事情:
<TextView
android:id="@+id/behindMenuItemLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:layout_weight="40"
android:drawablePadding="-5dp"
android:gravity="center_vertical"
android:text="Speak Now"
android:textColor="#000000"
style="@style/behindMenuItemLabel" />
Run Code Online (Sandbox Code Playgroud)
这是你的 style.xml
<style name="behindMenuItemLabel">
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_marginLeft">20dp</item>
<item name="android:layout_marginBottom">4dp</item>
<item name="android:textSize">30sp</item>
<item name="android:drawableLeft">@drawable/your_icon</item>
<item name="android:textColor">#d2d2d2</item>
</style>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8076 次 |
| 最近记录: |