为什么我的图像按钮周围会出现灰色边框?

时间:2014-07-07 20:26:47

标签: android android-imagebutton

我想将图像显示为按钮,但是当我使用ImageButton时,它会在按钮周围显示灰色边框。我希望它全黑,所以看起来它只是图像中的手电筒!有任何想法吗? (图像文件只是一个PNG文件)

这是我的fragment_display_message.xml:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    android:paddingBottom="@dimen/activity_vertical_margin"
    tools:context="com.example.myfirstapp.DisplayMessageActivity$PlaceholderFragment"
    android:gravity="center_horizontal"
    android:orientation="vertical"
    android:weightSum="1"
    android:background="@color/black" >

    <TextView
        android:id="@+id/text1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textColor="@color/white"
        android:layout_gravity="center_horizontal" />

    <TextView
        android:id="@+id/text2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textColor="@color/white"
        android:text="\n   It's a bit dark in here,\n       don't you think?\n\nLet's light it up by tapping\n         the flashlight!\n\n\n"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true" />

    <ImageButton
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/flashlight"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true" />

</LinearLayout>

3 个答案:

答案 0 :(得分:1)

从布局中删除这些行

android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"

答案 1 :(得分:0)

将ImageButton样式设置为无边框可能会有所帮助。

function newcolumnnumbers() {
var spreadsheet = SpreadsheetApp.getActive();
range = SpreadsheetApp.getActiveSheet().getLastRow();
spreadsheet.getCurrentCell().offset(0, 0, 2, 1).activate();
var destinationRange = spreadsheet.getActiveRange().offset(range, 0,0);
spreadsheet.getActiveRange().autoFill(destinationRange, 
SpreadsheetApp.AutoFillSeries.DEFAULT_SERIES);
// spreadsheet.getCurrentCell().offset(0, 0,range, 1).activate();
};

答案 2 :(得分:0)

使用 ImageView 代替 ImageButton