2016-07-15 46 views
0

我想为按钮内的黑色文本添加白色笔触。我可以想出使用普通的textview来做到这一点,但不涉及一个按钮。Xml:笔划,边框,按钮内部的轮廓文本

这是关于Xml的android工作室顺便说一句。

activity_main.xml中:

<Button 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:padding="5dip" 
    android:background="@drawable/login_button_style" 
    android:text="Log Ind" 
    android:id="@+id/button" 
    android:layout_alignParentBottom="true" 
    android:layout_alignParentLeft="true" 
    android:layout_alignParentStart="true" 
    android:layout_alignRight="@+id/editTextPass" 
    android:layout_alignEnd="@+id/editTextPass" 
    android:clickable="true" /><![CDATA[ 
/> 

login_button_style.xml:

<shape xmlns:android="http://schemas.android.com/apk/res/android" 
android:shape="rectangle" android:padding="10dp"> 
<solid android:color="#d7d7d7"/> 
<corners 
    android:bottomRightRadius="15dp" 
    android:bottomLeftRadius="15dp" 
    android:topLeftRadius="15dp" 
    android:topRightRadius="15dp"/> 
<stroke android:color="#d10f0f" android:width="3dp" /> 

<resources xmlns:android="http://schemas.android.com/apk/res/android"> 
    <style name="shadoweffect"> 
     <item name="android:paddingLeft">4px</item> 
     <item name="android:paddingBottom">4px</item> 
     <item name="android:textColor">#FFFFFF</item> 
     <item name="android:textSize">25sp</item> 
     <item name="android:shadowColor">#000000</item> 
     <item name="android:shadowDx">0</item> 
     <item name="android:shadowDy">0</item> 
     <item name="android:shadowRadius">3</item> 
    </style> 

</resources> 

enter image description here

有人可以告诉我吗?

+0

发布您的代码和图像,了解您确切需要什么以及发生了什么。 –

+0

没有图像。我们正在讨论Android Studio中的常规按钮,我想为其中的文本添加边框。 – Nulle

+0

你想要按钮边框还是只有文本边框?实际上两个库马尔都是 –

回答

0

看看这个答案,关于如何制作边框的类似问题。他创建一个新的文件,该文件仅仅是颜色的形状,然后将其作为绘制用作背景图像 https://stackoverflow.com/questions/7690416/android-border-for-button

的颜色就变成白色,且你去

编辑:

其实现在看。你想要的字母是,概述为白色。

所以我最好的猜测是绘制整个图像的文本和边框在Photoshop /素描。然后保存作为drawable。为您的按钮设置背景。请务必将按钮文字设置为引号,因为您已经拥有Photoshop模型中的文本。

android:text = ""