1

アプリのいくつかのボタンの高さを変更しようとしています。

私のアプリのスクリーンショット

@android:color/transparentとして設定してみました。また、のような値にandroid:background設定してみました。layout_height16dp

ボタンの高さを低くするにはどうすればよいですか?

スタイル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>

そしてレイアウト:

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/register_btn_privacy"
        android:text="@string/privacy_policy" 
        style="@style/Theme.PMBAppTheme.TextButton"
        />

text_button_text

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
    <item android:state_focused="true" android:state_pressed="true" android:color="@color/muted_pink_over" />
    <item android:state_focused="false" android:state_pressed="true" android:color="@color/muted_pink_over" /> 
    <item android:color="@color/muted_pink" /> 
</selector>
4

3 に答える 3

4

ボタンの高さを wrap_content に設定します。

android:layout_height="wrap_content"

テキストを表示するには、ボタンの高さを最小に設定する必要があります。

于 2013-02-25T18:04:43.443 に答える
1

Vapor API (最近リリースした Android 用の jQuery スタイル フレームワーク) には、 と呼ばれる使用可能なメソッドがあります.size(int,int)Viewこれにより、コンテナのタイプに応じてサイズが設定されます。次のようなものです:

$.Button(R.id.register_btn_privacy).size(int width, int height);

すばらしいのは、呼び出しをチェーンして、 の他のプロパティを調整することもできるということですView。例えば:

$.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

Vapor API の Web サイトに興味がある場合は、チェックしてみてください。基本的には、Android 開発をより簡単にし、jQuery を使用するように設計されています。

于 2013-02-26T09:27:27.637 に答える
1

これをスタイルから削除します

<item name="android:height">20sp</item>

だからあなたはで終わる

<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>

Buttonandroid:heightから継承しTextView、それに従って、これはおそらく高さを正確に設定し、あなたの.TextView layout_height

于 2013-02-26T15:12:17.760 に答える