Android: can height of SlidingDrawer be set with wrap_content?

后端 未结 6 2112
花落未央
花落未央 2020-11-27 10:38

I\'m trying to implement a SlidingDrawer that will occupy the full screen width, but whose height is determined dynamically by its contents: in other words, sta

6条回答
  •  孤街浪徒
    2020-11-27 11:21

    It works for me:

    private SlidingDrawer rightSlidingPanel = null;
    
     @Override 
    public void onCreate( Bundle savedInstanceState )
    {
    ...
        rightSlidingPanel = (SlidingDrawer) findViewById( R.id.rightSlidingPanel );
        rightSlidingPanel.post( new Runnable() 
                {
                    @Override
                    public void run()
                    {
                        rightSlidingPanel.getLayoutParams().width = findViewById( R.id.sliding_content2 ).getMeasuredWidth() + findViewById( R.id.sliding_handle ).getMeasuredWidth();
                    }
    
                });
    }
    

    XML Layout:

    ...
        
    
                

提交回复
热议问题