Android 更改按钮高度
我正在尝试更改应用程序中几个按钮的高度 我曾尝试将Android 更改按钮高度,android,android-layout,Android,Android Layout,我正在尝试更改应用程序中几个按钮的高度 我曾尝试将@android:color/transparent设置为android:background,并尝试将布局高度设置为16dp等值 我怎么能让我的纽扣的高度更小呢 以下是xml的样式: <style name="Theme.PMBAppTheme.TextButton"> <item name="android:textStyle">bold</item> <item name="and
@android:color/transparent
设置为android:background
,并尝试将布局高度设置为16dp
等值
我怎么能让我的纽扣的高度更小呢
以下是xml的样式:
<style name="Theme.PMBAppTheme.TextButton">
<item name="android:textStyle">bold</item>
<item name="android:textSize">14sp</item>
<item name="android:textColor">@drawable/text_button_text</item>
<item name="android:background">#ff3300</item>
<item name="android:padding">0dp</item>
<item name="android:height">20sp</item>
</style>
设置按钮的高度以包裹内容:
android:layout_height="wrap_content"
这应该将按钮的高度设置为最小值以显示其文本。将按钮的高度设置为包裹内容:
android:layout_height="wrap_content"
这应该将按钮的高度设置为显示文本的最小值。在(我刚刚发布的Android jQuery风格框架)中,有一种方法可以使用,叫做.size(int,int)
。这将根据它所在的容器类型设置视图的大小。比如:
$.Button(R.id.register_btn_privacy).size(int width, int height);
最酷的是,您还可以通过链式调用来调整视图的其他属性。例如:
$.Button(R.id.register_btn_privacy)
.size(50,100) // set size
.text("Privacy Policy") // set the text
.bgColor(Color.RED) // set the background color
.color(Color.WHITE); // set the text color
如果您对的感兴趣,请查看它,它基本上是为了让Android开发更容易,并且喜欢使用jQuery。在(我刚刚发布的Android的jQuery风格框架)中,有一种方法可以使用,叫做.size(int,int)
。这将根据它所在的容器类型设置视图的大小。比如:
$.Button(R.id.register_btn_privacy).size(int width, int height);
最酷的是,您还可以通过链式调用来调整视图的其他属性。例如:
$.Button(R.id.register_btn_privacy)
.size(50,100) // set size
.text("Privacy Policy") // set the text
.bgColor(Color.RED) // set the background color
.color(Color.WHITE); // set the text color
如果您对的感兴趣,请查看它,它基本上是为了让Android开发变得更简单,并且喜欢使用jQuery。将其从您的风格中删除
<item name="android:height">20sp</item>
20sp
所以你最终得到了
<style name="Theme.PMBAppTheme.TextButton">
<item name="android:textStyle">bold</item>
<item name="android:textSize">14sp</item>
<item name="android:textColor">@drawable/text_button_text</item>
<item name="android:background">#ff3300</item>
<item name="android:padding">0dp</item>
</style>
大胆的
14便士
@可绘制/文本按钮文本
#ff3300
0dp
按钮
继承自文本视图
,根据文本视图
,这可能会精确设置高度,并导致它忽略您的布局高度
将其从您的样式中删除
<item name="android:height">20sp</item>
20sp
所以你最终得到了
<style name="Theme.PMBAppTheme.TextButton">
<item name="android:textStyle">bold</item>
<item name="android:textSize">14sp</item>
<item name="android:textColor">@drawable/text_button_text</item>
<item name="android:background">#ff3300</item>
<item name="android:padding">0dp</item>
</style>
大胆的
14便士
@可绘制/文本按钮文本
#ff3300
0dp
按钮
继承自文本视图
,根据文本视图
,这可能会精确设置高度,并导致它忽略您的布局高度
您可以发布您的XML@Kirk-对不起,我完全忘了做。现在就在那儿,你能把你的信寄出去吗XML@Kirk-对不起,我完全忘了做。它现在就在那里。我已经将它设置为wrap\u content
,这会产生上面的结果:(我已经将它设置为wrap\u content
,这会产生上面的结果:(这看起来确实很有趣,但我真的只是刚开始android开发。如果能在没有任何额外框架/库的情况下学习如何做事情,那就太好了。公平了!把它扔出去,因为当我第一次来到android时,我发现它有点让人困惑。祝你好运这一切看起来都很有趣,但我很高兴。)真的只是从android开发开始。在没有任何额外的框架/库的情况下学习如何做事情会很好。这很公平!只是把它扔出去,因为当我第一次来到android时,我发现它有点让人困惑。祝你好运谢谢,但这也是不可能的。我想我必须使用TextView
并使其可点击,而不是按钮
。您是否也可以发布@drawable/text\u Button\u text
的定义?其中可能有意外情况。如果清理项目会发生什么?在样式的高度属性之后?如果同时从按钮中删除样式并精简项目?谢谢,但这也是不可能的。我想我必须使用TextView
,并使其可点击,而不是按钮
。你能不能也发布@drawable/text\u Button\u text
的定义?可能有什么意外的地方。如果你清理了项目,会发生什么?在y的高度属性之后我们的风格?如果你把你的按钮上的风格全部删除,然后清理项目,又会发生什么呢?