【问题标题】:Any idea how reproduce this Android button知道如何重现这个 Android 按钮
【发布时间】:2015-03-20 15:00:19
【问题描述】:

提前感谢您的宝贵时间。

我想重现这个 android 按钮,但不幸的是我花了几个小时才弄明白,但没有结果!

图片:http://i.stack.imgur.com/m0mSw.jpg

PS:我只想要左边的图标/背景和右边的标题,不需要事实计数器。

如果你有任何想法,请随时帮助我。

再次感谢。

【问题讨论】:

  • 您可以发布一些您尝试过的代码吗?
  • 您是否尝试过在 xml 中复制设计,并将按钮侦听器附加到布局?你走了多远?你安装了eclipse/android studio吗?或者您只是不确定在布局中使用什么比例?
  • @jasonwarford 我已经尝试使用 android:drawableLeft 和 android:background 指向另一个 xml 样式文件的 LinearLayout 来生成一个漂亮的平面按钮,您可以在此处查看结果:i.imgur.com/6dzCW9J.jpg 锁定这里的代码:i.imgur.com/SCQiJol.jpg
  • @EricS。感谢您的评论,我不确定是否应该在每个 LinearLayout 或其他任何内容中使用 ImageView 和 Button。我对 Android 有点陌生,如果你能知道如何重现这个按钮,我想知道。

标签: android android-layout button android-button


【解决方案1】:

试试RelativeLayout就这么简单

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@android:color/holo_blue_light">

   <ImageView
       android:id="@+id/icon"
       android:layout_width="80dp"
       android:layout_height="80dp"
       android:padding="24dp"
       android:src="@android:drawable/ic_dialog_info"
       android:background="@android:color/holo_blue_dark"/>

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_toRightOf="@+id/icon"
        android:layout_margin="8dp"
        android:text="Button text"
        android:textColor="@android:color/white"
        android:textAppearance="@android:style/TextAppearance.Holo.Medium"/>

</RelativeLayout>

【讨论】:

  • 谢谢!这个想法很棒,但我想我必须弄清楚更多,这是结果i.imgur.com/HYTpSTZ.jpg。我希望我能弄清楚如何用它编码!
猜你喜欢
  • 2011-03-21
  • 2019-12-13
  • 2017-06-04
  • 1970-01-01
  • 2016-07-14
  • 1970-01-01
  • 2022-08-18
  • 1970-01-01
相关资源
最近更新 更多