问题标签 [android-layout]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
android - Android - 在 LinearLayout 或 RelativeLayout 中为 View 的 topMargin/bottomMargin/etc 设置动画
我正在尝试创建一个从底部向上滑动的菜单。它从屏幕底部可见的菜单视图开始,然后单击它会使其向上滑动。我尝试使用 a TranslateAnimation
,但尽管像素移动,但菜单的命中区域与以前的位置相同。所以我认为如果我可以在动画完成后调整菜单的边距,这将完成我想要的。但是,我不知道如何调整边距。
我尝试创建一个LinearLayout.LayoutMargins
对象,然后设置其边距并将其应用于菜单的视图(即 a LinearLayout
),但这不起作用。
有任何想法吗?
android - 如何布局文本以围绕图像流动
你能告诉我是否有办法在图像周围布局文本?像这样:
我收到了一位 android 开发人员关于这个问题的回复。但我不确定他做我自己版本的 TextView 是什么意思?感谢任何提示。
2010 年 2 月 8 日星期一晚上 11:05,Romain Guy 写道:
你好,
仅使用提供的小部件和布局是不可能的。您可以编写自己的 TextView 版本来执行此操作,这应该不难。
java - Android 浮动视图(在其他视图之上)
我已经搞砸了几天了,希望这里有人可以帮我一把。
我有一个简单的两列布局,左侧是带按钮的导航栏,右侧是内容面板。当用户点击其中一个按钮(例如,向下的第三个按钮)时,我希望有一个浮动视图与此按钮的右侧对齐,但浮动在内容窗格的顶部。这是一张图片来说明我的意思:
我尝试过的所有操作都将浮动菜单推到导航栏或内容面板内,这不是我想要的。有任何想法吗?到目前为止,这基本上是我所拥有的:
android - 自定义布局管理器
我打算建立自己的自定义布局管理器。
除了扩展类之外,如果还有其他方法可以构建一个View
,因为这是我目前知道的唯一方法,并且想知道是否有其他方法可以做到这一点?
android - 如何以编程方式在 RelativeLayout 中布局视图?
我正在尝试以编程方式(而不是通过 XML 以声明方式)实现以下目标:
换句话说,我如何让第二个TextView
出现在第一个下面,但我想在代码中做到这一点:
更新:
谢谢,TreeUK。我理解大方向,但它仍然不起作用 - “B”与“A”重叠。我究竟做错了什么?
android - ListView 行样式 - 左对齐文本和右对齐图标
我试图让 ListView 行看起来如下所示:
与图像按钮对齐到右边缘。我怎样才能做到这一点?这是我正在使用的当前布局代码。我究竟做错了什么?
我的代码目前产生这个:
android - How to get RelativeLayout working with merge and include?
I have been trying for a few days now to make my layouts more efficient by converting from using several levels of nested LinearLayouts
to one RelativeLayout
and have come across a few problems that I haven not been able to find a workaround for...
I have searched the Android beginners group and this site and have not been able to find anything that would help me solve the problem.
I read on one of the blogs that you can combine layouts with merge and include tags. So what I have is a main layout file with a RelativeLayout
root element. Inside of that I have 5 include tags that reference 5 different xml layout files that each have a merge element for the root (all of my merge files are the same except for the ids in them).
I am running into two problems, which I will explain after posting a simplified version of my layout code:
Sample Main Layout File:
Sample included merge file:
I am running into two problems:
1) The android:layout_*
attributes seem to be ignored when used in the include tag and all of the merged layouts are displayed on top of each other. According to this post (http://developer.android.com/resources/articles/layout-tricks-reuse.html) "any android:layout_*
attribute can be used with the <include />
tag"
2) Since I couldn't get this working I decided to try adding an android:layout_below
attribute to the first TextView
item in each merge layout file, meaning that each merge file would be referencing an id from another merge layout file... For the most part this actually worked and my layout looks fine. However, I get an error on one of the android:layout_below
attributes saying that it can't find the id I specified... I have double and triple checked the ids to make sure they were correct. The weirdest part is that I used the AutoFill
feature to put the id in the attribute in the first place.
If anyone has any suggestions or workarounds I will be more than happy to try them out. Also, if anyone can think of a way for me to just have one merge xml layout file instead of 5 that would be greatly appreciated. I couldn't find a way to do that because I need to have access to each item in the merge layout files at runtime...
android - 如何使用布局膨胀一个视图
我有一个用 XML 定义的布局。它还包含:
我想用其他 XML 布局文件来扩充这个 RelativeView。我可能会根据情况使用不同的布局。我该怎么做?我正在尝试不同的变体
但它们都没有正常工作。
java - Android布局编辑器中的NotFoundException?
我正在尝试扩展一个 RelativeLayout 对象并包含一个嵌入的 SurfaceView 对象,该对象使用我的 /res/drawable 文件夹中的 png 文件作为其背景,但我在 XML 布局编辑器中不断收到错误消息。请参阅以下代码:
我收到以下错误:
NotFoundException:在当前配置中找不到可绘制资源匹配值 0x7F020002(解析名称:golf1)。
我现在可能已经看到这种类型的错误,当我尝试通过代码而不是 XML 从资源文件中加载某些内容时,它总是会发生。奇怪的是,这个错误并没有阻止我编译应用程序,并且应用程序在模拟器中运行没有错误。不过,我想重新使用我的布局编辑器...
请帮忙。
更新:这是布局 XML
android - How do I align views at the bottom of the screen?
Here's my layout code;
What this looks like is on the left and what I want it to look like is on the right.
The obvious answer is to set the TextView to fill_parent on height, but this causes no room to be left for the button or entry field.
Essentially the issue is that I want the submit button and the text entry to be a fixed height at the bottom and the text view to fill the rest of the space. Similarly, in the horizontal linear layout I want the submit button to wrap its content and for the text entry to fill the rest of the space.
If the first item in a linear layout is told to fill_parent it does exactly that, leaving no room for other items. How do I get an item which is first in a linear layout to fill all space apart from the minimum required by the rest of the items in the layout?
Relative layouts were indeed the answer: