android.widget.ScrollView.setFillViewport()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(9.9k)|赞(0)|评价(0)|浏览(142)

本文整理了Java中android.widget.ScrollView.setFillViewport()方法的一些代码示例,展示了ScrollView.setFillViewport()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ScrollView.setFillViewport()方法的具体详情如下:
包路径:android.widget.ScrollView
类名称:ScrollView
方法名:setFillViewport

ScrollView.setFillViewport介绍

暂无

代码示例

代码示例来源:origin: stackoverflow.com

ScrollView sView = (ScrollView) findViewById(R.id.scrollView2)
sView.removeAllViews();
sView.setFillViewport(true);

代码示例来源:origin: stackoverflow.com

@Override
public Object instantiateItem(View collection, int position) {
  ScrollView sc = new ScrollView(cxt);
  sc.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
  sc.setFillViewport(true);
  TextView tv = new TextView(cxt);
  tv.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
  tv.setText(pages[position]);
  tv.setPadding(5,5,5,5);         
  sc.addView(tv);
  ((ViewPager) collection).addView(sc);

  return sc;
  }

代码示例来源:origin: stackoverflow.com

ScrollView sc = new ScrollView(mContext);
sc.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
sc.setFillViewport(true);

sc.addView(ll);

代码示例来源:origin: stackoverflow.com

ScrollView sc = new ScrollView(this);
 sc.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
 sc.setFillViewport(true);
 LinearLayout layout = new LinearLayout(this);
 layout.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
 layout.setOrientation(LinearLayout.VERTICAL); 
 LinearLayout row = new LinearLayout(this);
 row.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
 Button btnTag = new Button(this);
 btnTag.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT,LayoutParams.WRAP_CONTENT));
 row.addView(btnTag);
 layout.addView(row);
 sc.addView(layout);

代码示例来源:origin: stackoverflow.com

ScrollView sc = new ScrollView(this);
sc.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
sc.setFillViewport(true);

代码示例来源:origin: Janseon/CardMenuView

protected final void setTitleScrollContentView(int layoutResID, boolean setBg, boolean setFillViewport) {
  LinearLayout layout = new LinearLayout(this);
  layout.setOrientation(LinearLayout.VERTICAL);
  title_view = new TextView(this);
  layout.addView(title_view, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
  scrollView = new ScrollView(this);
  if (setFillViewport) {
    scrollView.setFillViewport(true);
  }
  layout.addView(scrollView, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
  View.inflate(this, layoutResID, scrollView);
  super.setContentView(layout);
  if (setBg) {
    setBackGround(R.color.bg_gray);
  } else {
    getWindow().setBackgroundDrawable(null);
  }
}

代码示例来源:origin: stackoverflow.com

if(attrs.length() > 0) {
  ScrollView mScrollView = new HorizontalScrollView(getApplicationContext());
  mScrollView.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
  mScrollView.setFillViewport(true); 
  LinearLayout attrControlsSubContainer = new LinearLayout(getBaseContext());
  attrControlsSubContainer.setOrientation(LinearLayout.HORIZONTAL);
  LinearLayout.LayoutParams layoutParams= new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.WRAP_CONTENT);                               attrControlsSubContainer.setLayoutParams(layoutParams);
  for(int i=0;i<attrs.length();i++)
  {
    CheckBox chkAttribute = new CheckBox(getBaseContext());
    chkAttribute.setText(attrs.getJSONObject(i).getString("name"));
    chkAttribute.setTextColor(Color.BLACK);
    chkAttribute.setId(attrs.getJSONObject(i).getInt("id"));
    attrControlsSubContainer.addView(chkAttribute);
                 }
   mScrollView.addView(attrControlsSubContainer);
   attributeControlContainer.addView(mScrollView);  
}

代码示例来源:origin: jelic98/dynamico

@Override
  public View style(View view, JSONObject attributes) throws Exception {
    super.style(view, attributes);

    ScrollView scrollView = (ScrollView) view;

    if(attributes.has("fillViewport")) {
      scrollView.setFillViewport(attributes.getBoolean("fillViewport"));
    }

    if(attributes.has("smoothScrollingEnabled")) {
      scrollView.setSmoothScrollingEnabled(attributes.getBoolean("smoothScrollingEnabled"));
    }

    if(attributes.has("overScrollMode")) {
      String mode = attributes.getString("overScrollMode");

      if(mode.equalsIgnoreCase("always")) {
        scrollView.setOverScrollMode(ScrollView.OVER_SCROLL_ALWAYS);
      }else if(mode.equalsIgnoreCase("never")) {
        scrollView.setOverScrollMode(ScrollView.OVER_SCROLL_NEVER);
      }else if(mode.equalsIgnoreCase("if_content_scrolls")) {
        scrollView.setOverScrollMode(ScrollView.OVER_SCROLL_IF_CONTENT_SCROLLS);
      }
    }

    return scrollView;
  }
}

代码示例来源:origin: stackoverflow.com

ScrollView sv = new ScrollView(this);
 sv.setFillViewport(true);
 CustomLayout customLayout = new CustomLayout(this);
 LinearLayout linearLayout = new LinearLayout(this);
 linearLayout.setOrientation(LinearLayout.VERTICAL);
 for (int i = 0; i < 20; i++) {
   Button button = new Button(this);
   button.setText("Button" + i);
   linearLayout.addView(button);
 }
 customLayout.addView(linearLayout);
 sv.addView(customLayout);
 setContentView(sv);

代码示例来源:origin: stackoverflow.com

public class MainActivity extends Activity {

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
  }

  public void btnClick(View v){
    LinearLayout container = (LinearLayout)findViewById(R.id.container);
    ScrollView scroll = (ScrollView)findViewById(R.id.scroll);
    RelativeLayout layout1 = (RelativeLayout)findViewById(R.id.layout1);

    RelativeLayout layout2 = new RelativeLayout(this);
    LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, 300);
    layout2.setBackgroundColor(Color.YELLOW);

    layout1.getLayoutParams().height = scroll.getHeight();
    scroll.setFillViewport(false);
    container.addView(layout2, params);
  }

}

代码示例来源:origin: stackoverflow.com

LinearLayout layout = new LinearLayout(this);
   layout.setOrientation(LinearLayout.VERTICAL); 
   TextView menuText = new TextView(this);
   menuText.setText("People");
   menuText.setId(100);
   menuText.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
   layout.addView(menuText);
   for (int i = 0; i < 10; i++) {
     LinearLayout row = new LinearLayout(this);
     row.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
       Button btnTag = new Button(this);
       btnTag.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
       btnTag.setText( " " + i);
       btnTag.setId(1 + (i));
       row.addView(btnTag);
       btnTag.setOnClickListener(new View.OnClickListener() {
         public void onClick(View v) {
           String buttonText = "Unknown Person";
             Button b = (Button) findViewById(v.getId());
             buttonText = (String) b.getText();
           TextView tx = (TextView) findViewById(100);
           tx.setText(buttonText + " pressed.");
         }
       });
     ScrollView sc = new ScrollView(this);
     sc.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
     sc.setFillViewport(true);
     sc.addView(row);
     layout.addView(sc);
     setContentView(layout);

代码示例来源:origin: EmpireProject/EmpireMobile

ScrollView scroll = new ScrollView(MyApplication.getContext());
scroll.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 400));
scroll.setFillViewport(true);
LinearLayout PSlayout = new LinearLayout(MyApplication.getContext());
PSlayout.setOrientation(LinearLayout.VERTICAL);

代码示例来源:origin: EmpireProject/EmpireMobile

ScrollView scroll = new ScrollView(MyApplication.getContext());
scroll.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 400));
scroll.setFillViewport(true);
LinearLayout Pylayout = new LinearLayout(MyApplication.getContext());
Pylayout.setOrientation(LinearLayout.VERTICAL);

代码示例来源:origin: EmpireProject/EmpireMobile

ScrollView scroll = new ScrollView(MyApplication.getContext());
scroll.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 400));
scroll.setFillViewport(true);
LinearLayout Pylayout = new LinearLayout(MyApplication.getContext());
Pylayout.setOrientation(LinearLayout.VERTICAL);

代码示例来源:origin: EmpireProject/EmpireMobile

ScrollView scroll = new ScrollView(MyApplication.getContext());
scroll.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 400));
scroll.setFillViewport(true);
LinearLayout Extlayout = new LinearLayout(MyApplication.getContext());
Extlayout.setOrientation(LinearLayout.VERTICAL);

代码示例来源:origin: EmpireProject/EmpireMobile

ScrollView scroll = new ScrollView(MyApplication.getContext());
scroll.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 400));
scroll.setFillViewport(true);
LinearLayout Exfillayout = new LinearLayout(MyApplication.getContext());
Exfillayout.setOrientation(LinearLayout.VERTICAL);

代码示例来源:origin: EmpireProject/EmpireMobile

ScrollView scroll = new ScrollView(MyApplication.getContext());
scroll.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 400));
scroll.setFillViewport(true);
LinearLayout Exfillayout = new LinearLayout(MyApplication.getContext());
Exfillayout.setOrientation(LinearLayout.VERTICAL);

代码示例来源:origin: EmpireProject/EmpireMobile

ScrollView scroll = new ScrollView(MyApplication.getContext());
scroll.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 400));
scroll.setFillViewport(true);
LinearLayout Extlayout = new LinearLayout(MyApplication.getContext());
Extlayout.setOrientation(LinearLayout.VERTICAL);

代码示例来源:origin: EmpireProject/EmpireMobile

ScrollView scroll = new ScrollView(MyApplication.getContext());
scroll.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 400));
scroll.setFillViewport(true);
LinearLayout PSlayout = new LinearLayout(MyApplication.getContext());
PSlayout.setOrientation(LinearLayout.VERTICAL);

代码示例来源:origin: EmpireProject/EmpireMobile

ScrollView scroll = new ScrollView(MyApplication.getContext());
scroll.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, 400));
scroll.setFillViewport(true);
LinearLayout innerLayout = new LinearLayout(MyApplication.getContext());
innerLayout.setOrientation(LinearLayout.VERTICAL);

相关文章

ScrollView类方法