Java Code Examples for android.widget.ScrollView#setVisibility()

The following examples show how to use android.widget.ScrollView#setVisibility() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CameraStreamerActivity.java    From media-for-mobile with Apache License 2.0 6 votes vote down vote up
private void updateUI(boolean inProgress) {
    ImageButton settingsButton = (ImageButton)findViewById(R.id.settings);
    ImageButton captureButton = (ImageButton)findViewById(R.id.start);
    ImageButton changeCameraButton = (ImageButton) findViewById(R.id.change_camera);

    ScrollView container = (ScrollView)findViewById(R.id.effectsContainer);

    if (inProgress == false) {
        captureButton.setImageResource(R.drawable.rec_inact);
        settingsButton.setVisibility(View.VISIBLE);
        container.setVisibility(View.VISIBLE);
        changeCameraButton.setVisibility(View.VISIBLE);
    } else {
        captureButton.setImageResource(R.drawable.rec_act);
        settingsButton.setVisibility(View.INVISIBLE);
        container.setVisibility(View.INVISIBLE);
        changeCameraButton.setVisibility(View.INVISIBLE);
    }
}
 
Example 2
Source File: ConfirmOperationFragment.java    From hawkular-android-client with Apache License 2.0 5 votes vote down vote up
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    toolbar = (Toolbar) view.findViewById(R.id.toolbar);
    table = (TableLayout) view.findViewById(R.id.operation_param_table);
    execute = (Button) view.findViewById(R.id.execute);
    cancel = (Button) view.findViewById(R.id.cancel);
    operationDetail = (TextView) view.findViewById(R.id.operation_detail);
    custom = (SwitchCompat) view.findViewById(R.id.custom);
    scroll = (ScrollView) view.findViewById(R.id.scroll);

    resource = getResource();
    operation = getOperation();
    scroll.setVisibility(View.GONE);

    toolbar.setTitle(R.string.operation_confirm_title);

    setOperationDetail();

    BackendClient.of(ConfirmOperationFragment.this).getOperationProperties(new ConfirmOperationFragment.OperationPropertiesCallback(),
            operation, resource);

    execute.setOnClickListener(new ClickListner());
    cancel.setOnClickListener(new ClickListner());

    custom.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
            if (checked) {
                scroll.setVisibility(View.VISIBLE);
            } else {
                scroll.setVisibility(View.GONE);
            }
        }
    });
}
 
Example 3
Source File: WeatherActivity.java    From FoodOrdering with Apache License 2.0 4 votes vote down vote up
private void initWidget() {
        contentMian = (ScrollView) findViewById(R.id.content_main);
        contentMian.setVisibility(View.INVISIBLE);

        mCurrentAreaTv = (TextView) findViewById(R.id.tv_topCity);
        mCurrentAreaTv.setText("正在刷新");

        swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.refresh);
        swipeRefreshLayout.post(new Runnable() {
            @Override
            public void run() {
                swipeRefreshLayout.setRefreshing(true);
            }
        });

        swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
            @Override
            public void onRefresh() {
                refresh(false);
            }
        });

        mToolbar = (Toolbar) findViewById(R.id.toolbar);
        mToolbar.setTitle("");
        setSupportActionBar(mToolbar);

        mDrawerLayout = (DrawerLayout) findViewById(R.id.drawLayout);

        mFirstShowRl = findViewById(R.id.first_show_rl);

        TypedArray actionbarSizeTypedArray = this.obtainStyledAttributes(new int[]{android.R.attr.actionBarSize});
        int h = (int) actionbarSizeTypedArray.getDimension(0, 0);
        mFirstShowRl.getLayoutParams().height = ScreenUtil.getScreenHeight(this) - h - ScreenUtil.getStatusBarHeight(this);

//        setDrawerLayout();//加载侧滑栏菜单
        setRealWeather();
        setForeCast();
        setWind();
        setAqi();
        setSunRiseView();
        setZhiShu();
    }
 
Example 4
Source File: WallpaperActivity.java    From frost with GNU General Public License v3.0 4 votes vote down vote up
private void createLayout(int width) {
    float scale = ScreenUtils.densityScale(getApplicationContext());
    int margin = 16 * Math.round(scale);

    LinearLayout.LayoutParams baseParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
    LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
    LinearLayout.LayoutParams containerParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
    LinearLayout.LayoutParams imageParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT, 1f);

    ScrollView baseScroller = new ScrollView(this);
    baseScroller.setLayoutParams(baseParams);
    baseScroller.setBackgroundColor(getResources().getColor(R.color.colorLight));
    setContentView(baseScroller);
    baseScroller.setVisibility(View.VISIBLE);

    // display width hack
    Rect windowRect = new Rect();
    baseScroller.getWindowVisibleDisplayFrame(windowRect);
    int windowWidth = windowRect.right - windowRect.left;

    LinearLayout baseLayout = new LinearLayout(this);
    baseLayout.setOrientation(LinearLayout.VERTICAL);
    baseLayout.setLayoutParams(layoutParams);
    baseLayout.setPadding(margin, margin, 0, 0);
    baseScroller.addView(baseLayout);

    String[] wallpapers = getResources().getStringArray(R.array.wallpapers);
    for (int i = 0; i < wallpapers.length; i++) {
        if ((i % width) == 0) {
            layoutList.add((i / width), new LinearLayout(this));
            layoutList.get(i / width).setOrientation(LinearLayout.HORIZONTAL);
            layoutList.get(i / width).setGravity(Gravity.START);
            layoutList.get(i / width).setLayoutParams(containerParams);

            baseLayout.addView(layoutList.get(i / width));
        }
        imageList.add(i, new ImageView(this));
        imageList.get(i).setLayoutParams(imageParams);
        imageList.get(i).setScaleType(ImageView.ScaleType.FIT_XY);
        imageList.get(i).setPadding(0, 0, margin, margin);
        imageList.get(i).setAdjustViewBounds(true);

        final int resId = getResources().getIdentifier(wallpapers[i], "drawable", getPackageName());
        ImageUtils.bitmapLoadAsync(imageList.get(i), getApplicationContext().getResources(), resId,
                (windowWidth / width) - (margin * width + margin) / width,
                (windowWidth / width) - (margin * width + margin) / width);

        layoutList.get(i / width).addView(imageList.get(i));
        imageList.get(i).setOnClickListener(v -> wallpaperView(resId));
    }
}
 
Example 5
Source File: IconActivity.java    From frost with GNU General Public License v3.0 4 votes vote down vote up
private void createLayout(int width) {
    float scale = ScreenUtils.densityScale(getApplicationContext());
    int margin = 16 * Math.round(scale);

    LinearLayout.LayoutParams baseParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
    LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
    LinearLayout.LayoutParams containerParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
    LinearLayout.LayoutParams imageParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT, 1f);

    ScrollView baseScroller = new ScrollView(this);
    baseScroller.setLayoutParams(baseParams);
    baseScroller.setBackgroundColor(getResources().getColor(R.color.colorPrimary));
    setContentView(baseScroller);
    baseScroller.setVisibility(View.VISIBLE);

    // display width hack
    Rect windowRect = new Rect();
    baseScroller.getWindowVisibleDisplayFrame(windowRect);
    int windowWidth = windowRect.right - windowRect.left;

    LinearLayout baseLayout = new LinearLayout(this);
    baseLayout.setOrientation(LinearLayout.VERTICAL);
    baseLayout.setLayoutParams(layoutParams);
    baseLayout.setPadding(margin, margin, 0, 0);
    baseScroller.addView(baseLayout);

    String[] images = getResources().getStringArray(R.array.icon_pack);
    for (int i = 0; i < images.length; i++) {
        if ((i % width) == 0) {
            layoutList.add((i / width), new LinearLayout(this));
            layoutList.get(i / width).setOrientation(LinearLayout.HORIZONTAL);
            layoutList.get(i / width).setGravity(Gravity.START);
            layoutList.get(i / width).setLayoutParams(containerParams);

            baseLayout.addView(layoutList.get(i / width));
        }
        imageList.add(i, new ImageView(this));
        imageList.get(i).setLayoutParams(imageParams);
        imageList.get(i).setScaleType(ImageView.ScaleType.FIT_XY);
        imageList.get(i).setPadding(0, 0, margin, margin);
        imageList.get(i).setAdjustViewBounds(true);

        final int resId = getResources().getIdentifier(images[i], "drawable", getPackageName());
        ImageUtils.bitmapLoadAsync(imageList.get(i), getApplicationContext().getResources(), resId, (windowWidth / width) - (margin * width + margin) / width, (windowWidth / width) - (margin * width + margin) / width);

        layoutList.get(i / width).addView(imageList.get(i));
    }
}
 
Example 6
Source File: WeatherFragment.java    From YourWeather with Apache License 2.0 4 votes vote down vote up
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View view  = inflater.inflate(R.layout.activity_weather,container,false);
    swipeRefresh = (SwipeRefreshLayout) view.findViewById(R.id.swipe_layout);
    scrWeatherLayout = (ScrollView)view.findViewById(R.id.weather_scrollView);
    tempText = (TextView) view.findViewById(R.id.temp);
    imgWeather= (ImageView)view.findViewById(R.id.img_cond);
    weatherInfoText = (TextView)view.findViewById(R.id.weather_info);
    hourforecastLayout= (LinearLayout)view.findViewById(R.id.hour_layout);
    forecastLayout = (LinearLayout)view.findViewById(R.id.forecast_layout);
    aqiText = (TextView)view.findViewById(R.id.aqi_text);
    airQlty= (TextView)view.findViewById(R.id.airQlty);
    pm25Text = (TextView)view.findViewById(R.id.pm2_5);
    airBrf = (TextView)view.findViewById(R.id.sug_air);
    comfBrf= (TextView)view.findViewById(R.id.sug_comf);
    fluBrf= (TextView)view.findViewById(R.id.sug_flu);
    drsgBrf= (TextView)view.findViewById(R.id.sug_drsg);
    airTxt = (TextView)view.findViewById(R.id.air_txt);
    comfortTxt = (TextView)view.findViewById(R.id.comf_txt);
    influenzaTxt = (TextView)view.findViewById(R.id.flu_txt);
    dressTxt = (TextView)view.findViewById(R.id.drsg_txt);

    weatherId = (String) getArguments().get("weather_id");
        scrWeatherLayout.setVisibility(View.INVISIBLE);
        if (weatherId !=null) {
            requestWeather(weatherId);

        }
        //刷新控件的实现

    swipeRefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
            @Override
            public void onRefresh() {
                if (weatherId!=null){
                    requestWeather(weatherId);
                    Toast.makeText(getActivity(), "更新成功( •̀ .̫ •́ )✧", Toast.LENGTH_SHORT).show();
                }else{
                    Log.d("LifeCycle","swipeWeatherId is null");
                }

            }
        });
    Log.d("LifeCycle","WeatherFragment_onCreateView");
    return view;
}
 
Example 7
Source File: WeatherActivity.java    From coolweather with Apache License 2.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (Build.VERSION.SDK_INT >= 21) {
        View decorView = getWindow().getDecorView();
        decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
                | View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
        getWindow().setStatusBarColor(Color.TRANSPARENT);
    }
    setContentView(R.layout.activity_weather);
    // 初始化各控件
    bingPicImg = (ImageView) findViewById(R.id.bing_pic_img);
    weatherLayout = (ScrollView) findViewById(R.id.weather_layout);
    titleCity = (TextView) findViewById(R.id.title_city);
    titleUpdateTime = (TextView) findViewById(R.id.title_update_time);
    degreeText = (TextView) findViewById(R.id.degree_text);
    weatherInfoText = (TextView) findViewById(R.id.weather_info_text);
    forecastLayout = (LinearLayout) findViewById(R.id.forecast_layout);
    aqiText = (TextView) findViewById(R.id.aqi_text);
    pm25Text = (TextView) findViewById(R.id.pm25_text);
    comfortText = (TextView) findViewById(R.id.comfort_text);
    carWashText = (TextView) findViewById(R.id.car_wash_text);
    sportText = (TextView) findViewById(R.id.sport_text);
    swipeRefresh = (SwipeRefreshLayout) findViewById(R.id.swipe_refresh);
    swipeRefresh.setColorSchemeResources(R.color.colorPrimary);
    drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    navButton = (Button) findViewById(R.id.nav_button);
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
    String weatherString = prefs.getString("weather", null);
    if (weatherString != null) {
        // 有缓存时直接解析天气数据
        Weather weather = Utility.handleWeatherResponse(weatherString);
        mWeatherId = weather.basic.weatherId;
        showWeatherInfo(weather);
    } else {
        // 无缓存时去服务器查询天气
        mWeatherId = getIntent().getStringExtra("weather_id");
        weatherLayout.setVisibility(View.INVISIBLE);
        requestWeather(mWeatherId);
    }
    swipeRefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            requestWeather(mWeatherId);
        }
    });
    navButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            drawerLayout.openDrawer(GravityCompat.START);
        }
    });
    String bingPic = prefs.getString("bing_pic", null);
    if (bingPic != null) {
        Glide.with(this).load(bingPic).into(bingPicImg);
    } else {
        loadBingPic();
    }
}
 
Example 8
Source File: MainActivity.java    From MyWeather with Apache License 2.0 4 votes vote down vote up
private void initWidget() {
    contentMian = (ScrollView) findViewById(R.id.content_main);
    contentMian.setVisibility(View.INVISIBLE);

    mCurrentAreaTv = (TextView) findViewById(R.id.tv_topCity);
    mCurrentAreaTv.setText("正在刷新");

    swipeRefreshLayout = (SwipeRefreshLayout) findViewById(R.id.refresh);
    swipeRefreshLayout.post(new Runnable() {
        @Override
        public void run() {
            swipeRefreshLayout.setRefreshing(true);
        }
    });

    swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            refresh(false);
        }
    });

    mToolbar = (Toolbar) findViewById(R.id.toolbar);
    mToolbar.setTitle("");
    setSupportActionBar(mToolbar);

    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawLayout);

    mFirstShowRl = findViewById(R.id.first_show_rl);

    TypedArray actionbarSizeTypedArray = this.obtainStyledAttributes(new int[]{android.R.attr.actionBarSize});
    int h = (int) actionbarSizeTypedArray.getDimension(0, 0);
    mFirstShowRl.getLayoutParams().height = ScreenUtil.getScreenHeight(this) - h - ScreenUtil.getStatusBarHeight(this);

    setDrawerLayout();
    setRealWeather();
    setForeCast();
    setWind();
    setAqi();
    setSunRiseView();
    setZhiShu();
}
 
Example 9
Source File: PicDetailActivity.java    From NetEasyNews with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Object instantiateItem(ViewGroup container, int position) {
    View view = View.inflate(mContext, R.layout.fragment_pic_detail, null);
    ImageView iv_pic = (ImageView) view.findViewById(R.id.iv_pic);
    TextView tv_title = (TextView) view.findViewById(R.id.tv_title);
    TextView tv_pic_sum = (TextView) view.findViewById(R.id.tv_pic_sum);
    final ScrollView sv_content = (ScrollView) view.findViewById(R.id.sv_content);
    TextView tv_pic_content = (TextView) view.findViewById(R.id.tv_pic_content);
    String setName = mImageDetailBean.getSetname();
    String postid = mImageDetailBean.getPostid();
    ImageDetailBean.PhotosBean photosBean = mImageDetailBean.getPhotos().get(position);
    LogUtils.d(TAG, setName);
    String title = photosBean.getImgtitle();
    String note = photosBean.getNote();
    isGone = false;
    if (title != null && !title.equals("")) {
        tv_title.setText(title);
    } else if (setName != null && !setName.equals("")){
        tv_title.setText(setName);
    } else {
        tv_title.setText(postid);
    }

    if (note != null) {
        tv_pic_content.setText(note);
        isGone = false;
    } else {
        sv_content.setVisibility(View.GONE);
        isGone = true;
    }

    tv_pic_sum.setText((position + 1) + "/" + mImageDetailBean.getPhotos().size());

    Glide.with(mContext)
            .load(photosBean.getImgurl())
            .placeholder(R.drawable.defaultbg)
            .centerCrop()
            .crossFade()
            .into(iv_pic);

    iv_pic.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (isGone) {
                sv_content.setVisibility(View.VISIBLE);
                isGone = false;
            } else {
                sv_content.setVisibility(View.GONE);
                isGone = true;
            }
        }
    });

    container.addView(view);

    return view;
}