为什么Android API 15级中 "按钮栏中的按钮应该是无边界的"? 您所在的位置:网站首页 buttonbarbuttonstyle 为什么Android API 15级中 "按钮栏中的按钮应该是无边界的"?

为什么Android API 15级中 "按钮栏中的按钮应该是无边界的"?

2023-08-29 15:52| 来源: 网络整理| 查看: 265

百度翻译此文   有道翻译此文 问题描述

I'm developing an application for Android and I recently changed the API level target from 8 to 15, and now Eclipse is warning me when the Buttons are inside Linear Layouts or Table Rows.

The same doesn't happen when the Button is in a Relative Layout.

The warning says:

Buttons in button bars should be borderless; use style="?android:attr/buttonBarButtonStyle" (and ?android:attr/buttonBarStyle on the parent)

I can get rid of the warning by following the suggestion or even by suppressing it, but I'm interested to know why this now? What's wrong with bordered buttons?

推荐答案

The borderless buttons are for cohesiveness of design throughout the android platform. It's recommended you follow the guidelines so that the user feels that your app is native and does not stick out like a sore thumb, but there are many cases where it just doesn't make sense, like if it makes your app look unprofessional. If that is the case, you may want to turn off the warning.

To turn off the warning, go to the project properties -> Android Lint Preferences. Search for "border" or "ButtonStyle" and change the severity to ignore on the bottom right.

You can also do this in Eclipse preferences for all projects.

For Android Studio Users: File -> Settings -> Editor -> Inspections -> Android Lint. Search for "borderless" and uncheck or change the severity.

其他推荐答案Here is another simple way to get rid of it.

The compiler is trying to tell you to set the style of the button. So simply add the following style for the Android default borderless style and the error will be gone.

Here is the proof

enter image description here

其他推荐答案

In my case adding that style to ALL buttons which were ONLY elements in some linerar layout gave buttons without any borders. After adding style also to the layout I got buttons separated with small edges exsacly like in some epements of my (4.1.2) android interface eg. like in dialog possitive/negative buttons. It worked correctly. Standard Holo buttons are ugly but with that styles they look "professional";-)



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有