2016-12-01 5 views
1

Google 행 아웃처럼 하단에 팝업으로 TextView을 만들려고합니다. Google 행 아웃 앱은 xxx로 로그인 한 상태로 몇 초 동안 팝업을 표시합니다. 당신은 내가 LinearLayout 내부 TextView를 넣어시피 NavigationView의 DrawerLayout에 팝업을 표시하는 방법

나는이 고전 탐색 창 레이아웃

<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:id="@+id/drawer" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:fitsSystemWindows="true" 
    tools:context="com.port.android.ui.ActivityMain"> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:orientation="vertical"> 

     <include 
      android:id="@+id/toolbar" 
      layout="@layout/tool_bar" /> 

     <FrameLayout 
      android:id="@+id/frame" 
      android:layout_width="match_parent" 
      android:layout_height="0dp" 
      android:layout_weight="1"> 
     </FrameLayout> 

     <TextView 
      android:id="@+id/popup_logged_in" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:background="@color/PrimaryColor" 
      android:layout_alignParentBottom="true" 
      android:padding="15dp" 
      android:textSize="14sp" 
      android:visibility="gone" 
      android:gravity="center" 
      android:textColor="@android:color/white" 
      android:textAllCaps="true" 
      android:textStyle="bold" /> 

    </LinearLayout> 

    <android.support.design.widget.NavigationView 
     android:id="@+id/navigation_view" 
     android:layout_width="wrap_content" 
     android:layout_height="match_parent" 
     android:layout_gravity="start" 
     app:headerLayout="@layout/navigation_view_header" 
     app:menu="@menu/menu_navigation"> 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_gravity="bottom" 
      android:padding="20dp" 
      android:orientation="horizontal"> 
      <Button 
       android:id="@+id/btn_exit" 
       android:layout_width="0dp" 
       android:layout_height="wrap_content" 
       android:layout_weight="1" 
       android:onClick="exitAddress" 
       android:text="Exit Address"/> 

     </LinearLayout> 
    </android.support.design.widget.NavigationView> 
</android.support.v4.widget.DrawerLayout> 

을 가지고 있고 그것은 내가 view.animate()을 수행 할 때 표시 할 수 있지만 최대 레이아웃을 밀어 나는 그것이에 있고 싶어 상단. 그래서 나는 RelativeLayout을 시도하지만 그것은 도구 모음을 사라지게 만들었습니다.

Here's AppCompatActivity을 도움이된다면은 :

@Override 
protected void onCreate(Bundle savedInstanceState) { 
    if (Application.getInstance().isClosing()) 
     finish(); 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.activity_main); 
    popUpThreadPoolFactory = new PopUpThreadPoolFactory(this); 
    fragManager = getSupportFragmentManager(); 
    mMainAdapter = new ActivityMainAdapter(this); 
    // Initializing Toolbar and setting it as the actionbar 
    mToolbar = (Toolbar) findViewById(R.id.toolbar); 
    setSupportActionBar(mToolbar); 
    //Initializing NavigationView 
    mNavigationView = (NavigationView) findViewById(R.id.navigation_view); 
    mNavigationView.setNavigationItemSelectedListener(this); 
    // Initializing Drawer Layout and ActionBarToggle 
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer); 
    ((Button) findViewById(R.id.btn_exit)).setOnClickListener(new OnClickListener() { 
     @Override 
     public void onClick(View v) { 
      FirebaseManager.getInstance().exitCurrentAddress(); 
     } 
    }); 

    mActionBarDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, mToolbar, R.string.openDrawer, R.string.closeDrawer) { 
     @Override 
     public void onDrawerClosed(View drawerView) { 
      // Code here will be triggered once the drawer closes as we dont want anything to happen so we leave this blank 
      super.onDrawerClosed(drawerView); 
     } 

     @Override 
     public void onDrawerOpened(View drawerView) { 
      // Code here will be triggered once the drawer open as we dont want anything to happen so we leave this blank 
      super.onDrawerOpened(drawerView); 
     } 
    }; 
    //Setting the actionbarToggle to drawer layout 
    mDrawerLayout.addDrawerListener(mActionBarDrawerToggle); 
    //calling sync state is necessay or else your hamburger icon wont show up 
    mActionBarDrawerToggle.syncState(); 
    // Initialize Firebase Analytics 
    mFirebaseAnalytics = FirebaseAnalytics.getInstance(this); 

    // ATTENTION: This was auto-generated to implement the App Indexing API. 
    // See https://g.co/AppIndexing/AndroidStudio for more information. 
    client2 = new GoogleApiClient.Builder(this).addApi(AppIndex.API).build(); 
} 

@Override 
protected void onStart() { 
    super.onStart(); 
    // ATTENTION: This was auto-generated to implement the App Indexing API. 
    // See https://g.co/AppIndexing/AndroidStudio for more information. 
    client2.connect(); 
    // ATTENTION: This was auto-generated to implement the App Indexing API. 
    // See https://g.co/AppIndexing/AndroidStudio for more information. 
    Action viewAction = Action.newAction(
      Action.TYPE_VIEW, // TODO: choose an action type. 
      "ActivityMain Page", // TODO: Define a title for the content shown. 
      // TODO: If you have web page content that matches this app activity's content, 
      // make sure this auto-generated web page URL is correct. 
      // Otherwise, set the URL to null. 
      Uri.parse("http://host/path"), 
      // TODO: Make sure this auto-generated app URL is correct. 
      Uri.parse("android-app://com.port.android/http/host/path") 
    ); 
    AppIndex.AppIndexApi.start(client2, viewAction); 
} 

@Override 
protected void onResume() { 
    super.onResume(); 
    MyLog.i(TAG, "onResume"); 
    Application.getInstance().addUIListener(OnConnectionStateListener.class, this); 
    Application.getInstance().addUIListener(OnExitAddressListener.class, this); 
    Application.getInstance().addUIListener(OnUserSignedInListener.class, this); 
    // update state 
    if (Application.getInstance().isInitialized() && !Application.getInstance().isClosing()) { 
     MyLog.i(TAG, "Application isInitialized activating adapter"); 
     mainAdapterOnChange(); 
    } else 
     MyLog.i(TAG, "Wait for loading or closing"); 
} 
+0

내 사랑하는 사람 activty.xml을 게시 할 수 있습니다. –

+0

감사합니다. 일부 활동 코드를 추가했습니다. –

답변

2

난 당신이 스낵바에 대한 검색 생각합니다.. 이것이 당신이 시도하는 것이라면 여기에 한 예가 있습니다. 당신의 activity.java 클래스에 activity.xml

<android.support.design.widget.CoordinatorLayout  
    xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:fitsSystemWindows="true" 
android:id="@+id/cd" 
tools:context="com.example.ayyappaboddupalli.dragmaker.MainActivity"> 


:

이 보여주고 싶은 당신 활동에

, 당신의 부모 Layout.Suppose 바인딩

CoordinatorLayout cd=(CoodinatorLayour)findViewById(R.id.cd); 

버튼 클릭시 팝업을 표시하려면 다음과 같이하십시오.

btn.setOnClickListener(new onClickListener() 

    public void onClick(View v) 
    { 
    Snackbar.make(cd,"text you want to show",Snackbar.LENGTH_LONG).show(); 
    } 
    ); 
+0

'Snackbar'는 som을 시도 할 것임을 결코 알지 못했습니다. 생각 해봐야 모든 시스템 메시지와 사용자 정의 메시지가 내 팝업으로 들어갑니다. 그것은 모두'ConcurrentLinkedQueue'와'Thread'로 제어됩니다. 기본적으로 나는'showPopup (text, duration, style);과 같은 메시지를 보낼 수 있습니다.'Snackbar'가 도움이 될지 모르지만 테스트 할 것입니다. –

+0

안녕하세요. [snackbar] (https://www.youtube.com/watch ? v = KGS7O2wzz_Y)는 내 친구입니다 –

+0

예, 나는 그것을 아주 좋아할 것입니다. –