草庐IT

border-width

全部标签

android - 布局 : how to make image to change its width and height proportionally?

我有这样的布局:这个布局几乎满足了我的需要:它使ImageView的高度与TextView的高度相同。图像图形内容拉伸(stretch)也保持纵横比。但是,ImageView的宽度不会改变!结果,我在文本和ImageView之间有很大的差距!作为临时解决方案,我覆盖了View#onLayout。问题:如何在xml布局中改变图片宽度?更新:这是我需要的最终布局(文本+一些图像)。查看第一张图片:它的宽度应该与其中缩放后的图片完全相同,没有填充和边距: 最佳答案 对于imageView,您可以将图像添加到线性布局并赋予权重属性。例如,如

android - 如何实现 Material Design "Full-width text field"?

我想实现MaterialDesign中的“全角文本字段”,如下所示:https://www.google.com/design/spec/components/text-fields.html#text-fields-full-width-text-field我如何使用MaterialDesign库做到这一点?最新版本中至少有这些可用的库:com.android.support:design:23.0.1com.android.support:appcompat-v7:23.0.1com.android.support:support-v4:23.0.1我从EditText开始:看起来

android - 布局问题 : SliderDrawer doesn't fill parent width

我在Android中使用SliderDrawer。在抽屉里,我有一个布局,其中包含一个膨胀的布局。这是最终结果:请注意抽屉的内容(灰色)如何不占用父级(黑色区域)的整个宽度。这是抽屉代码(main_layout.xml):[更新2,添加了整个代码:]这里是充气区域的代码(media_player_container.xml):你能发现我做错了什么吗??[更新1]这是我膨胀布局的代码(在onCreate()内部):LinearLayoutcontainer=(LinearLayout)this.findViewById(R.id.media_player_container);Layou

Android SeekBar 长度与 layout_width 值不匹配

我正在尝试在布局中制作一个带有硬编码宽度的搜索栏,但是,一旦搜索栏的硬编码宽度值超过某个值,搜索栏的宽度将不会反射(reflect)我设置的值。例如:产生一个短的搜索栏,因为宽度决定它应该只有50dp长。这是布局:现在,当我将layout_width更改为300dp时,我看到一个截断的搜索栏,它肯定不是300dp长。这是文件和布局:注意:seekbar似乎被限制在相对布局(红色矩形)的宽度内,任何时候seekbar的长度(由android:layout_width指定)都会超过宽度RelativeLayout的长度是有上限的。如何让我的搜索栏符合我想要的硬编码长度?编辑:我在下面包含了

android - 创建不需要在 XML 中设置 layout_width/height 的自定义 View

是否可以创建一个自定义View,以便它可以被引用没有在xml中明确说明layout_width和layout_height,因为这已经在CustomView类中定义publicclassCustomViewextendsTextView{publicCustomView(Contextcontext){super(context);setup();}publicCustomView(Contextcontext,@NullableAttributeSetattrs){super(context,attrs);setup();}publicCustomView(Contextcontex

Android Border Less 按钮按下状态背景色

我们如何在按下按钮时更改无边框按钮的背景颜色。我用过这个:android:background="?android:attr/selectableItemBackground"android:text="@string/btn_skip"我的按钮显示在我的“strings.xml”中定义的标签“SKIP”。现在当我测试它时,它很好,除了它在按下状态时显示默认的“蓝色”颜色。我希望它与我的UI主题中“橙色”“#FF8800”的其他元素相匹配有什么想法吗?提前谢谢...! 最佳答案 除了使用?android:attr/selectabl

java - 二进制 XML 文件行 #7 : You must supply a layout_width attribute

每当这段代码被执行时:inflater.inflate(R.layout.settings_switch,this);我收到这个错误:10-2913:27:00.090:E/AndroidRuntime(22364):Causedby:java.lang.RuntimeException:BinaryXMLfileline#7:您必须提供layout_width属性。怎么可能呢?我有android:layout_width="match_parent"android:layout_height="match_parent" 最佳答案

Android Studio 烦人的 layout_width 和 layout_height 弹出窗口

我在Mac上使用AndroidStudio2.2.3。每当我在布局资源XML中添加新元素时,layout_width和layout_height属性都会自动完成,并且光标会跳转到layout_width的值>(这很好)。问题是,在很短的时间后,没有做任何事情,一个弹出窗口出现了match_parent或wrap_content的文档,我必须关闭这个窗口在输入layout_width的值之前手动设置。然后光标跳到layout_height并再次重复相同的过程。添加新View时,这非常烦人。谁能重现这个问题,或者谁知道防止它发生的方法?下面是问题的GIF动画:

Android RelativeLayout 和 layout_width ="match_parent"的 child

当我在同一“行”有两个View,一个width="fill_parent"时,Android如何计算View的大小?例子:此代码为EditText提供所有可用空间,并在其右侧显示按钮。但是随着这个改变,EditText填充了所有的宽度并且按钮在屏幕之外: 最佳答案 android:layout_toLeftOf="@+id/Button01"将强制EditText的右边界与Button的左侧对齐,因此Android会忽略match_parentwidth强制宽度只填充从左父侧到按钮的右侧。android:layout_toRight

android - layout_width 和 layout_height 不适用于主题中的 edittext

下面我在主题中添加了EditText样式。我也添加了宽度和高度。所以我从我的edittextView中删除了android:layout_width和android:layout_height。但它说的是错误。如果我添加宽度和高度,它工作正常。有什么不同。主题不适用于我的edittextView吗?@style/custom_EditTextStyle@drawable/edittextboxtruefill_parent48dp我的editTextView 最佳答案 你的styles.xml必须包含在顶部。如果这个文件是自动生成的