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

在我的情况下,按钮将位于任何位置,也可以在中心.但主要的是我如何在EditText中放置一个按钮?
我正在将背景图像设置为我的自定义按钮.我为我的应用程序制作了截图,并提到当我使用"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文件.您可以查看此链接以查看我的问题的屏幕截图: …
我有一个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文件吗?
有人可以帮我创建如下的自定义按钮吗?可能吗?已经搜索了很多,并且只能找到一些再次成为的东西rectangular/square shapes.但我希望两个按钮triangular可以安排在另一个上,并且只能在他们特定的占用区域上点击.代码片段表示赞赏.

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

问题:
当点击按钮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.
如何解决它.
如果有任何解决方案,请分享它.
谢谢.
如果我按下操作栏中的按钮,那么它的背景颜色不是我想要的.我的项目的背景颜色不响应我的点击事件.如何更改此项并在按下时更改背景颜色?
嗨,我需要这样做因为,我正在进行匹配/记忆游戏,并且必须有一个按钮(与当前游戏中的按钮完全分开),当我按下它时,它必须自动显示匹配的卡片必须用鼠标触摸按钮.
按下按钮是否有"按下"功能或类似功能?
谢谢!:)
这是来自具有转发器的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) 我不知道如何将图标置于按钮内并将其置于文本上方,我也没有找到有关它的信息,我被要求做一种"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
谢谢!