Android: make a scrollable custom view

前端 未结 3 1509
春和景丽
春和景丽 2021-01-02 13:28

I\'ve rolled my own custom view and can draw to the screen alright, but what I\'d really like to do is set the measuredHeigh of the screen to, say, 1000px and let the user s

3条回答
  •  被撕碎了的回忆
    2021-01-02 14:19

    If you are wanting the entire activity to be a ScrollView, then do something like this:

    
    
    
      
    
        
    
        
    
      
    
    
    

    Then the activity that uses this layout can look something like this:

    public class ScrollingActivity extends Activity
    {
        public void onCreate(Bundle savedInstanceState)
        {
            super.onCreate(savedInstanceState);
    
            this.setContentView(R.layout.scroll_layout);
        }
    }
    

    This assumes that the name of your xml file is scroll_layout.xml.

提交回复
热议问题