本文介绍了Android的衰落/调光像菜单选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些图标的布局。当我在底部触摸一个图标,在底部的屏幕的1/4西港岛线变得像我自己创建一个选项菜单。

I have an layout with some icons. When i touch one icon on the bottom, in the 1/4 of the screen on the bottom wil become something like an option menu which I created myself.

我的目标是褪色现在/ DIMM屏幕的其余部分,除1/4在底部。一个还让屏幕不活动的一部分,就像在optionMenu android系统中。

My goal is to fade / dimm now the rest of the screen, except the 1/4 on the bottom. An also to make this part of the screen inactive, like for the optionMenu in android.

你有什么想法,我怎么能做到这一点?我Shuld创建两个单独的布局,其中一个图标,另一个与菜单?

Do you have any idea how could I do this? Shuld I create two separate layouts, one with the icons and another with the menu?

感谢您。

下面是马云初始布局:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/bg" >


 <RelativeLayout
     android:id="@+id/mainRelativeLayout"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     android:layout_alignParentBottom="true"
     android:layout_alignParentLeft="true"
     android:layout_alignParentRight="true"
     android:layout_alignParentTop="true"
     android:layout_marginLeft="10dp"
     android:layout_marginTop="10dp" >

     <TextView
         android:id="@+id/CenterTextViewJournals"
         android:layout_width="wrap_content"
         android:layout_height="20dp"
         android:layout_centerHorizontal="true"
         android:layout_centerVertical="true"
         android:text="         " />

     <ImageView
         android:id="@+id/invisibleImageView"
         android:layout_width="120dp"
         android:layout_height="120dp"
         android:layout_centerHorizontal="true"
         android:layout_centerVertical="true" />

     <ImageView
         android:id="@+id/EditorialBoard"
         android:layout_width="120dp"
         android:layout_height="120dp"
         android:layout_above="@+id/CenterTextViewJournals"
         android:layout_centerHorizontal="true"
         android:onClick="goEditorialBoard"
         android:src="@drawable/button_about_active" />

     <ImageView
         android:id="@+id/Contact"
         android:layout_width="120dp"
         android:layout_height="120dp"
         android:layout_alignBottom="@+id/CenterTextViewJournals"
         android:layout_toRightOf="@+id/CenterTextViewJournals"
         android:onClick="goContact"
         android:src="@drawable/button_about_active" />

     <ImageView
         android:id="@+id/AimsAndScope"
         android:layout_width="120dp"
         android:layout_height="120dp"
         android:layout_alignBottom="@+id/CenterTextViewJournals"
         android:layout_toLeftOf="@+id/CenterTextViewJournals"
         android:onClick="goAimsAndScope"
         android:src="@drawable/button_about_active" />

     <ImageView
         android:id="@+id/Articles"
         android:layout_width="180dp"
         android:layout_height="180dp"
         android:layout_centerHorizontal="true"
         android:layout_centerVertical="true"
         android:onClick="goArticles"
         android:paddingBottom="9px"
         android:paddingLeft="6px"
         android:paddingRight="8px"
         android:paddingTop="4px"
         android:src="@drawable/button_about_active" />

 </RelativeLayout>


<ImageView
    android:id="@+id/StartSelectingDifferentJournal"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_alignParentLeft="true"
    android:scaleType="fitXY"
    android:src="@drawable/journal_selecting_barr" />

<Gallery
    android:id="@+id/gallery"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_above="@+id/SelectDifferentJournaleditText"
    android:layout_alignParentLeft="true"
    android:gravity="bottom" />

<EditText
    android:id="@+id/SelectDifferentJournaleditText"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_centerHorizontal="true"
    android:layout_alignParentBottom="true"
    android:visibility="gone"
    android:hint="Search Journal">
</EditText>

<ImageView
    android:id="@+id/SelectingDifferentJournal"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_above="@+id/gallery"
    android:layout_alignParentLeft="true"
    android:layout_alignParentRight="true"
    android:gravity="bottom"
    android:scaleType="fitXY"
    android:src="@drawable/journal_selecting_barr" />

推荐答案

好吧,这里是这样做的,但你将不得不修改你的布局设置的简单方法。

Alright, here's a simple way of doing this, but your going to have to modify your layout setup.

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/bg" >


 <RelativeLayout
     android:id="@+id/mainRelativeLayout"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     android:layout_alignParentBottom="true"
     android:layout_alignParentLeft="true"
     android:layout_alignParentRight="true"
     android:layout_alignParentTop="true"
     android:layout_marginLeft="10dp"
     android:layout_marginTop="10dp" >

     <TextView
         android:id="@+id/CenterTextViewJournals"
         android:layout_width="wrap_content"
         android:layout_height="20dp"
         android:layout_centerHorizontal="true"
         android:layout_centerVertical="true"
         android:text="         " />

     <ImageView
         android:id="@+id/invisibleImageView"
         android:layout_width="120dp"
         android:layout_height="120dp"
         android:layout_centerHorizontal="true"
         android:layout_centerVertical="true" />

     <ImageView
         android:id="@+id/EditorialBoard"
         android:layout_width="120dp"
         android:layout_height="120dp"
         android:layout_above="@+id/CenterTextViewJournals"
         android:layout_centerHorizontal="true"
         android:onClick="goEditorialBoard"
         android:src="@drawable/button_about_active" />

     <ImageView
         android:id="@+id/Contact"
         android:layout_width="120dp"
         android:layout_height="120dp"
         android:layout_alignBottom="@+id/CenterTextViewJournals"
         android:layout_toRightOf="@+id/CenterTextViewJournals"
         android:onClick="goContact"
         android:src="@drawable/button_about_active" />

     <ImageView
         android:id="@+id/AimsAndScope"
         android:layout_width="120dp"
         android:layout_height="120dp"
         android:layout_alignBottom="@+id/CenterTextViewJournals"
         android:layout_toLeftOf="@+id/CenterTextViewJournals"
         android:onClick="goAimsAndScope"
         android:src="@drawable/button_about_active" />

     <ImageView
         android:id="@+id/Articles"
         android:layout_width="180dp"
         android:layout_height="180dp"
         android:layout_centerHorizontal="true"
         android:layout_centerVertical="true"
         android:onClick="goArticles"
         android:paddingBottom="9px"
         android:paddingLeft="6px"
         android:paddingRight="8px"
         android:paddingTop="4px"
         android:src="@drawable/button_about_active" />

 </RelativeLayout>


<ImageView
    android:id="@+id/StartSelectingDifferentJournal"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_alignParentLeft="true"
    android:scaleType="fitXY"
    android:src="@drawable/journal_selecting_barr" />
</RelativeLayout>
<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:id="@+id/dimmer_layout"/>
<RelativeLayout
    layout_width="match_parent"
    layout_height="match_parent">
<Gallery
    android:id="@+id/gallery"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_above="@+id/SelectDifferentJournaleditText"
    android:layout_alignParentLeft="true"
    android:gravity="bottom" />

<EditText
    android:id="@+id/SelectDifferentJournaleditText"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_centerHorizontal="true"
    android:layout_alignParentBottom="true"
    android:visibility="gone"
    android:hint="Search Journal">
</EditText>

<ImageView
    android:id="@+id/SelectingDifferentJournal"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_above="@+id/gallery"
    android:layout_alignParentLeft="true"
    android:layout_alignParentRight="true"
    android:gravity="bottom"
    android:scaleType="fitXY"
    android:src="@drawable/journal_selecting_barr" />
</RelativeLayout>
</FrameLayout>

在菜单被打开,设置线性布局的背景为透明的黑色像0x55000000。

When the menu gets opened, set the Linear Layout's background to a transparent black like 0x55000000.

void onMenuOpen() {
    openTheMenu();
    LinearLayout llDimmer = (LinearLayout)findViewById(R.id.dimming_layout);
    llDimmer.setBackgroundColor(0x55000000);
}

然后就可以在菜单关闭后,背景色设置为0x00000000。

Then you can set the background color to 0x00000000 after the menu closes.

这篇关于Android的衰落/调光像菜单选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-22 22:58