我不明白为什么我的图标以这种方式格式化。它们被设置为填充父级,但事实并非如此。我正在尝试制作底部导航栏。我想要最后两个按钮具有的漂亮渐变,但按钮中的图像似乎从未正确格式化。如果我去掉布局中的背景,它们的格式会更好,但不完全是我想要的。我在此之后对酒吧进行建模:
我认为最好将所有 Imagebtn 设置为具有 @null 背景,然后当用户位于该页面上时,将深色渐变设置为父级中的背景,并将灰色渐变设置为 Imagebtn 中的背景。
我不确定完成最终游戏的最佳方式。这是我的 xml:
<LinearLayout android:id="@+id/navbar"
android:layout_alignParentBottom="true"
android:layout_width="fill_parent" android:background="@drawable/navbackground"
android:layout_height="60dip" android:layout_weight="1"
android:orientation="horizontal">
<ImageButton android:layout_height="fill_parent" android:id="@+id/navhomebtn" android:enabled="false"
android:textColor="#FFF" android:src="@drawable/homeiconsel" android:background="@null"
android:layout_weight=".25" android:layout_width="0dip" />
<ImageButton android:layout_height="fill_parent" android:id="@+id/navsearchbtn"
android:textColor="#FFF" android:background="#FFF"
android:text="Search" android:layout_weight=".25" android:src="@drawable/searchicon"
android:layout_width="0dip" />
<ImageButton android:layout_height="fill_parent" android:id="@+id/navfavbtn"
android:textColor="#FFF" android:background="@drawable/navbuttons"
android:src="@drawable/favoriteicon" android:layout_weight=".25"
android:layout_width="0dip" />
<ImageButton android:layout_height="fill_parent" android:id="@+id/navloanbtn"
android:textColor="#FFF" android:background="@drawable/navbuttons"
android:src="@drawable/loanicon" android:layout_weight=".25"
android:layout_width="0dip" />
</LinearLayout>
注意:粉红色背景只是我在 Google Dev Resources 此处,我会将其更改为较暗的渐变,但我想突出显示问题。
I can't figure out why my icons are formatting in this way. They are set to fill the parent but are not. I am trying to make a bottom navbar. I wanted a nice gradient which the last two buttons have but the images in the button never seem to format correctly. If I take out the background in the layout they format better but not quite what I want. I'm modeling the bar after this:
I thought it would be best to set all the Imagebtns to have @null background then have the dark gradient as the background in the parent and the gray gradient set as background in the Imagebtn when the user is on that page.
I'm not sure of the best way of trying to accomplish my end game. Here is my xml:
<LinearLayout android:id="@+id/navbar"
android:layout_alignParentBottom="true"
android:layout_width="fill_parent" android:background="@drawable/navbackground"
android:layout_height="60dip" android:layout_weight="1"
android:orientation="horizontal">
<ImageButton android:layout_height="fill_parent" android:id="@+id/navhomebtn" android:enabled="false"
android:textColor="#FFF" android:src="@drawable/homeiconsel" android:background="@null"
android:layout_weight=".25" android:layout_width="0dip" />
<ImageButton android:layout_height="fill_parent" android:id="@+id/navsearchbtn"
android:textColor="#FFF" android:background="#FFF"
android:text="Search" android:layout_weight=".25" android:src="@drawable/searchicon"
android:layout_width="0dip" />
<ImageButton android:layout_height="fill_parent" android:id="@+id/navfavbtn"
android:textColor="#FFF" android:background="@drawable/navbuttons"
android:src="@drawable/favoriteicon" android:layout_weight=".25"
android:layout_width="0dip" />
<ImageButton android:layout_height="fill_parent" android:id="@+id/navloanbtn"
android:textColor="#FFF" android:background="@drawable/navbuttons"
android:src="@drawable/loanicon" android:layout_weight=".25"
android:layout_width="0dip" />
</LinearLayout>
Note: The pinkish background was just something I was playing around with from Google Dev Resources here, I would change it to a darker gradient but I wanted to highlight the problem.
发布评论
评论(1)
我拿了你的 xml 并替换了我自己的图像。
一切似乎都正常。
也许您的布局嵌套的任何内容都会影响事物。
屏幕截图和代码如下:
I took your xml and replaced my own images in.
Everything seems to work ok.
Maybe whatever your layout is nested in is affecting things.
Screenshot and code below: