简体   繁体   English

如何将按钮放入两种布局

[英]How to place a button into two layout

I have three buttons in one row within a linear layout and just below a list is placed within another linear layout. 我在线性布局中的一行中有三个按钮,而在另一个线性布局中的列表正下方。 I want to place some part of one button (like an arrow) in the first item of the list . 我想将一个按钮的某个部分(如箭头)放在列表​​的第一项中。 (To indicate that the list is result for the button clicked). (以指示该列表是单击按钮的结果)。 How it possible? 怎么可能? plz help . 请帮助。 I want to do like the image given below. 我想做下面的图片。 在此处输入图片说明

Idea for your view, Coding is your task. 您的想法,编码是您的任务。

Top Most Parent is RelativeLayout . 父级最高的是RelativeLayout

|----- Relative Layout.
        |--- LinearLayout-1 --> City, Country, Global ( all weight = 1 )
        |--- LinearLayout-2 --> ( layout_below="LinearLayout-1" )
                  |--- 3 x ImageView  ( all weight = 1, Gravity=Center )
                       |--- Use View.SetVisibility(View.Invisible) to show/hide
        |--- ListView --> ( layout_below="LinearLayout-1" ) // Still below LL1.

浮动视图

Instead of horizontal linear layout with buttons you could go for tabs. 可以使用选项卡代替带有按钮的水平线性布局。 And here you can read how to achieve that arrow effect. 在这里您可以阅读如何实现箭头效果。

Create one image with arrow pointing down at the center. 创建一个图像,其箭头指向下方。 When you click on any button, in your OnClickListener, add a code the replace the button image with this new image. 当您单击任何按钮时,请在OnClickListener中添加代码,用此新图像替换按钮图像。

btnCity.setBackground(getResources().getDrawable(R.drawable.selectedbtnimage)); btnCity.setBackground(getResources()getDrawable(R.drawable.selectedbtnimage));

You will need to add some more code the reset the images of other buttons to origninal button images. 您将需要添加更多代码,以将其他按钮的图像重置为原始按钮图像。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM