标签: button

android中EditText内的可点击按钮(或任何视图)

我希望在EditText中有一个Button或一个可点击的View,以便我可以点击它执行一些操作.由于Marcosbeirigo的回答,我能够将一个drawable放在我的EditText中.但是,现在我想让它可点击,以便我可以对它执行一些操作.我知道这是可能的,因为HTC在他们的股票短信应用程序中使用EditText内的按钮,如下图所示 -

在EditText中发送按钮

在我的情况下,按钮将位于任何位置,也可以在中心.但主要的是我如何在EditText中放置一个按钮?

android button android-edittext

10
推荐指数
2
解决办法
2万
查看次数

按钮背景图像拉伸(wrap_content或dp用法)

我正在将背景图像设置为我的自定义按钮.我为我的应用程序制作了截图,并提到当我使用"wrap_content"作为按钮的宽度和高度时,按钮被拉伸.当我在dp中修改大小时,它会显得很好(例如:在我的mdpi文件夹中,我有48x48px图标,所以我把48dp放在宽度和高度上).你能解释一下为什么吗?

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/definition_layout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:padding="5dp"
android:layout_alignParentTop="true" >

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/buttons"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:padding="5dp" >

    <Button
        android:id="@+id/addToFavorites"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="5dp"
        android:background="@drawable/favorites_button" />

    <Button
        android:id="@+id/fontup"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="5dp"
        android:background="@drawable/fontup_button" />

    <Button
        android:id="@+id/fontdown"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="5dp"
        android:background="@drawable/fontdown_button" />

    <Button
        android:id="@+id/comment"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="5dp"
        android:background="@drawable/comment_button" />

    <Button
        android:id="@+id/speak"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_margin="5dp"
        android:background="@drawable/speak_button" />
    </LinearLayout>

    <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent" 
        android:layout_height="fill_parent"
        android:layout_below="@id/buttons">

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content">

    <ImageView
        android:id="@+id/image_frame"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />
    <WebView
        android:id="@+id/webView1"
        android:layout_below="@id/image_frame"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />
    </LinearLayout>
    </ScrollView>

    </RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

上面的代码显示了我的XML文件.您可以查看此链接以查看我的问题的屏幕截图: …

android button background-image android-linearlayout

10
推荐指数
3
解决办法
2万
查看次数

由png和overlay组成的XML drawable

我有一个png按钮,启用,非按下.当用户点击按钮时,我只想让png变暗.我需要这样的东西:

  <selector xmlns:android="http://schemas.android.com/apk/res/android" >
  //normal button with background my_button.png
        <item 
            android:state_enabled="true" 
            android:drawable="@drawable/my_button"   //my_button.png
            />
  //pressed button with background my_button.png overlayed by 50% black
        <item 
            android:state_pressed="true"
            android:state_enabled="true"    
            >
            <RelativeLayout 
               android:layout_width="wrap_content"
               android:layout_height="wrap_content">

              <bitmap  android:src="@drawable/my_button"/>
              <color android:color="#00000088"/>
            </RelativeLayout>
        </item>      
    </selector>
Run Code Online (Sandbox Code Playgroud)

有什么方法可以做到这一点?或者我必须有另一个png文件吗?

xml png android button drawable

10
推荐指数
1
解决办法
4759
查看次数

创建两个自定义按钮

有人可以帮我创建如下的自定义按钮吗?可能吗?已经搜索了很多,并且只能找到一些再次成为的东西rectangular/square shapes.但我希望两个按钮triangular可以安排在另一个上,并且只能在他们特定的占用区域上点击.代码片段表示赞赏.

在此输入图像描述

android button custom-component

10
推荐指数
1
解决办法
1275
查看次数

IOS键盘默认按钮翻译

实际上,我需要将十进制键盘键盘上的"done"/"pref"/"next"按钮翻译成俄语或其他语言.顺便说一句,应用程序的本地化俄语.此外,当我改变本地化语言时,所有其他按钮,如其他控制中的"取消",都会自动翻译.但不是这个.它可以在没有定制的情况下完成吗?

keyboard translation button ios

10
推荐指数
1
解决办法
936
查看次数

如何解决Android中按钮问题的双击?

我的申请样本:

双击样机


问题:

当点击按钮1,它只是调用意向的ActivitySecond

button1.setOnClickListener(this);

public void onClick(View v) {
// TODO Auto-generated method stub
     switch (v.getId()) 
     {
          case R.id.button1:
                Intent intent = new Intent(getApplicationContext(), ActivitySecond.class);
                startActivity(intent);
                break;
          default:
                break;
     }
}
Run Code Online (Sandbox Code Playgroud)

但是,在双击它打开两次 ActivitySecond.


如何解决它.

如果有任何解决方案,请分享它.

谢谢.

android button double-click android-activity

10
推荐指数
3
解决办法
1万
查看次数

按下时更改操作栏按钮背景颜色

如果我按下操作栏中的按钮,那么它的背景颜色不是我想要的.我的项目的背景颜色不响应我的点击事件.如何更改此项并在按下时更改背景颜色?

android background colors button android-actionbar

10
推荐指数
1
解决办法
1万
查看次数

有没有办法按下按钮而不在tkinter/python上触摸它?

嗨,我需要这样做因为,我正在进行匹配/记忆游戏,并且必须有一个按钮(与当前游戏中的按钮完全分开),当我按下它时,它必须自动显示匹配的卡片必须用鼠标触摸按钮.

按下按钮是否有"按下"功能或类似功能?

谢谢!:)

python user-interface tkinter button

10
推荐指数
2
解决办法
5220
查看次数

ASP.Net:为什么我的按钮的点击/命令事件没有在转发器中绑定/触发?

这是来自具有转发器的ascx的代码:

<asp:Repeater ID="ListOfEmails" runat="server" >
    <HeaderTemplate><h3>A sub-header:</h3></HeaderTemplate>
    <ItemTemplate>
        [Some other stuff is here]
        <asp:Button ID="removeEmail" runat="server" Text="X" ToolTip="remove" />
    </ItemTemplate>
</asp:Repeater>
Run Code Online (Sandbox Code Playgroud)

在转发器的数据绑定和事件的代码隐藏中:

Protected Sub ListOfEmails_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles ListOfEmails.ItemDataBound
    If (e.Item.ItemType = ListItemType.Item) Or (e.Item.ItemType = ListItemType.AlternatingItem) Then
        Dim removeEmail As Button = CType(e.Item.FindControl("removeEmail"), Button)
        removeEmail.CommandArgument = e.Item.ItemIndex.ToString()

        AddHandler removeEmail.Click, AddressOf removeEmail_Click
        AddHandler removeEmail.Command, AddressOf removeEmail_Command
    End If
End Sub

Sub removeEmail_Click(ByVal sender As Object, ByVal e As System.EventArgs)
    Response.Write("<h1>click</h1>")
End Sub

Sub removeEmail_Command(ByVal sender …
Run Code Online (Sandbox Code Playgroud)

vb.net asp.net repeater button .net-2.0

9
推荐指数
1
解决办法
2万
查看次数

Xamarin XAML按钮中的中心图标和文本

我不知道如何将图标置于按钮内并将其置于文本上方,我也没有找到有关它的信息,我被要求做一种"tabb"选项菜单,但在屏幕下方,我发现它有点"难",因为"设计含义"等,所以我决定使用按钮会更容易,但现在的问题是如何使图像居中并使文本正确,如果有人可以帮助我,那会很棒.到目前为止这是我的代码:

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
         xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
         BackgroundColor="Silver"
         x:Class="XamForm.View.MainPage">
<Label Text="{Binding MainText}" VerticalOptions="Center"  HorizontalOptions="Center" />


 <StackLayout Padding="30">
<Label x:Name="lblCuantos" Text="No #" TextColor="Gray" FontSize="20"/>
<Label x:Name="lblNombre" Text="" FontSize="20"/>
<Button  x:Name="btn1" Text="Oprimir" Clicked="Accion"/>
<Button  x:Name="btn2"  BackgroundColor="White" Image="iconRes.png"  HorizontalOptions="CenterAndExpand" Text="Gridd" TextColor="Gray" Clicked="Accion2"/>
<Button  x:Name="btn3"  BackgroundColor="White" Image="iconRes.png"  HorizontalOptions="CenterAndExpand"  TextColor="Gray" Clicked="Accion2"/>


</StackLayout>
</ContentPage>
Run Code Online (Sandbox Code Playgroud)

这是按钮本身的实际结果:

http://oi59.tinypic.com/11so9le.jpg

这就是菜单的最终结果应该看起来很像

http://oi62.tinypic.com/10pzw2f.jpg

谢谢!

xaml image button xamarin

9
推荐指数
1
解决办法
3万
查看次数