Java Code Examples for android.widget.listview#setVerticalScrollBarEnabled()

The following examples show how to use android.widget.listview#setVerticalScrollBarEnabled() . 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: PreferenceFragment.java    From MDPreference with Apache License 2.0 5 votes vote down vote up
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    ListView listView = (ListView) view.findViewById(android.R.id.list);
    listView.setPadding(PADDING_LEFT_RIGHT, 0, PADDING_LEFT_RIGHT, 0);
    listView.setHorizontalScrollBarEnabled(false);
    listView.setVerticalScrollBarEnabled(false);
    listView.setFooterDividersEnabled(false);
}
 
Example 2
Source File: EditDatabaseActivity.java    From AndroidFaceRecognizer with MIT License 5 votes vote down vote up
private void initialize(){
	DisplayMetrics dm = new DisplayMetrics();
	getWindowManager().getDefaultDisplay().getMetrics(dm);
	
	screenWidth = dm.widthPixels;
	screenHeight = dm.heightPixels;
	
	final TextView headerText = (TextView)findViewById(R.id.dbeditHeaderText);
	RelativeLayout.LayoutParams headerTextParams = (RelativeLayout.LayoutParams)headerText.getLayoutParams();
	headerTextParams.leftMargin = screenHeight/8;
	headerText.setLayoutParams(headerTextParams);
	headerText.setTextSize(TypedValue.COMPLEX_UNIT_DIP,(float)screenHeight/45);
	headerText.setText("Face DataBase");
	headerText.setTextColor(Color.LTGRAY);
	headerText.setGravity(Gravity.LEFT | Gravity.CENTER_VERTICAL);
	headerText.setTypeface(null, Typeface.BOLD);
	
	
	ListView listView = (ListView)findViewById(R.id.dbeditListView);
	ListAdapter listAdapter = new ListAdapter();
	listView.setAdapter(listAdapter);
	listView.setOnItemClickListener(itemClickListener);
	listView.setVerticalScrollBarEnabled(true);
	listView.setFastScrollEnabled(true);
	
	RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams)listView.getLayoutParams();
	params.leftMargin = screenWidth/40;
	params.rightMargin = screenWidth/40;
	//params.topMargin = screenHeight/40;
	listView.setLayoutParams(params);
	listView.setVerticalScrollBarEnabled(false);
}
 
Example 3
Source File: NiceSpinner.java    From nice-spinner with Apache License 2.0 5 votes vote down vote up
public void showDropDown() {
    if (!isArrowHidden) {
        animateArrow(true);
    }
    popupWindow.setAnchorView(this);
    popupWindow.show();
    final ListView listView = popupWindow.getListView();
    if(listView != null) {
        listView.setVerticalScrollBarEnabled(false);
        listView.setHorizontalScrollBarEnabled(false);
        listView.setVerticalFadingEdgeEnabled(false);
        listView.setHorizontalFadingEdgeEnabled(false);
    }
}
 
Example 4
Source File: NormalListDialog.java    From FlycoDialog_Master with MIT License 5 votes vote down vote up
@Override
public View onCreateView() {
    LinearLayout ll_container = new LinearLayout(mContext);
    ll_container.setOrientation(LinearLayout.VERTICAL);

    /** title */
    mTvTitle = new TextView(mContext);
    mTvTitle.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
            LinearLayout.LayoutParams.WRAP_CONTENT));
    mTvTitle.setSingleLine(true);
    mTvTitle.setPadding(dp2px(18), dp2px(10), 0, dp2px(10));

    ll_container.addView(mTvTitle);

    /** listview */
    mLv = new ListView(mContext);
    mLv.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
            LinearLayout.LayoutParams.WRAP_CONTENT));
    mLv.setCacheColorHint(Color.TRANSPARENT);
    mLv.setFadingEdgeLength(0);
    mLv.setVerticalScrollBarEnabled(false);
    mLv.setSelector(new ColorDrawable(Color.TRANSPARENT));

    ll_container.addView(mLv);

    return ll_container;
}
 
Example 5
Source File: NormalListDialog.java    From SprintNBA with Apache License 2.0 5 votes vote down vote up
@Override
public View onCreateView() {
    LinearLayout ll_container = new LinearLayout(mContext);
    ll_container.setOrientation(LinearLayout.VERTICAL);

    /** title */
    mTvTitle = new TextView(mContext);
    mTvTitle.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
            LinearLayout.LayoutParams.WRAP_CONTENT));
    mTvTitle.setSingleLine(true);
    mTvTitle.setPadding(dp2px(18), dp2px(10), 0, dp2px(10));

    ll_container.addView(mTvTitle);

    /** listview */
    mLv = new ListView(mContext);
    mLv.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
            LinearLayout.LayoutParams.WRAP_CONTENT));
    mLv.setCacheColorHint(Color.TRANSPARENT);
    mLv.setFadingEdgeLength(0);
    mLv.setVerticalScrollBarEnabled(false);
    mLv.setSelector(new ColorDrawable(Color.TRANSPARENT));

    ll_container.addView(mLv);

    return ll_container;
}
 
Example 6
Source File: SettingFragment.java    From MemoryCleaner with Apache License 2.0 5 votes vote down vote up
@Override public void initPreferenceListView(View view) {
    ListView listView = (ListView) view.findViewById(android.R.id.list);
    listView.setHorizontalScrollBarEnabled(false);
    listView.setVerticalScrollBarEnabled(false);
    listView.setDivider(
            new ColorDrawable(getResources().getColor(R.color.grey)));
    listView.setDividerHeight((int) getResources().getDimension(
            R.dimen.preference_divider_height));
    listView.setFooterDividersEnabled(false);
    listView.setHeaderDividersEnabled(false);
}
 
Example 7
Source File: TwoLevelSelectLayout.java    From SoloPi with Apache License 2.0 5 votes vote down vote up
/**
 * 初始化界面
 * @param context
 * @param attrs
 * @param style
 */
private void initView(Context context, AttributeSet attrs, int style) {
    setOrientation(HORIZONTAL);

    int dividerColor;
    if (Build.VERSION.SDK_INT >= 23) {
        dividerColor = getResources().getColor(R.color.divider_color, context.getTheme());
    } else {
        dividerColor = getResources().getColor(R.color.divider_color);
    }

    Context styledContext = ContextUtil.getContextThemeWrapper(context, R.style.selectListView);

    // 左侧FirstLevel
    firstLevel = new ListView(styledContext);
    firstLevel.setVerticalScrollBarEnabled(false);

    LayoutParams params = new LayoutParams(ContextUtil.dip2px(context, 50), ViewGroup.LayoutParams.MATCH_PARENT);
    addView(firstLevel, params);

    // 分割线
    View divider = new View(context, attrs, style);
    divider.setBackgroundColor(dividerColor);
    LayoutParams dividerParam = new LayoutParams(1, ViewGroup.LayoutParams.MATCH_PARENT);
    addView(divider, dividerParam);

    // 右侧滚动条
    secondLevel = new ListView(styledContext);
    LayoutParams secondParams = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT, 1.0F);
    addView(secondLevel, secondParams);
}
 
Example 8
Source File: FirstTimeSetupFragment.java    From FreezeYou with Apache License 2.0 5 votes vote down vote up
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    ListView listView = view.findViewById(android.R.id.list);
    if (listView != null) {
        listView.setVerticalScrollBarEnabled(false);
        listView.setOverScrollMode(View.OVER_SCROLL_NEVER);
    }
}
 
Example 9
Source File: FaceppActionActivity.java    From MegviiFacepp-Android-SDK with Apache License 2.0 5 votes vote down vote up
private void init() {
    mDialogUtil = new DialogUtil(this);
    TextView title = (TextView) findViewById(R.id.title_layout_titleText);
    title.setText(getResources().getString(R.string.title));
    findViewById(R.id.title_layout_returnRel).setVisibility(View.GONE);
    Button enterBtn = (Button) findViewById(R.id.landmark_enterBtn);
    enterBtn.setText(getResources().getString(R.string.detect_face));
    enterBtn.setOnClickListener(this);
    mInflater = LayoutInflater.from(this);
    findViewById(R.id.activity_rootRel).setOnClickListener(this);
    mListRel = (RelativeLayout) findViewById(R.id.landmark_listRel);
    mListRel.setOnClickListener(this);
    mListView = (ListView) findViewById(R.id.landmark_list);
    mListView.setVerticalScrollBarEnabled(false);

    mListAdapter = new ListAdapter();
    mListView.setAdapter(mListAdapter);
    RelativeLayout rel0 = (RelativeLayout) findViewById(R.id.landmark_imageitem_0);
    RelativeLayout rel1 = (RelativeLayout) findViewById(R.id.landmark_imageitem_1);
    RelativeLayout rel2 = (RelativeLayout) findViewById(R.id.landmark_imageitem_2);
    RelativeLayout rel3 = (RelativeLayout) findViewById(R.id.landmark_imageitem_3);
    RelativeLayout rel4 = (RelativeLayout) findViewById(R.id.landmark_imageitem_4);
    RelativeLayout rel5 = (RelativeLayout) findViewById(R.id.landmark_imageitem_5);
    RelativeLayout rel6 = (RelativeLayout) findViewById(R.id.landmark_imageitem_6);
    RelativeLayout rel7 = (RelativeLayout) findViewById(R.id.landmark_imageitem_7);
    imageItem_Rels = new RelativeLayout[]{rel0, rel1, rel2, rel3, rel4, rel5, rel6, rel7};
    RelativeLayout textRel0 = (RelativeLayout) findViewById(R.id.landmark_edititem_0);
    RelativeLayout textRel1 = (RelativeLayout) findViewById(R.id.landmark_edititem_1);
    RelativeLayout textRel2 = (RelativeLayout) findViewById(R.id.landmark_edititem_2);
    RelativeLayout textRel3 = (RelativeLayout) findViewById(R.id.landmark_edititem_3);
    RelativeLayout textRel4 = (RelativeLayout) findViewById(R.id.landmark_edititem_4);
    textItem_Rels = new RelativeLayout[]{textRel0, textRel1, textRel2, textRel3, textRel4};
}
 
Example 10
Source File: SuperDialog.java    From SuperDialog with Apache License 2.0 5 votes vote down vote up
/**
 * 列表显示,显示列表屏蔽按钮
 */
private void initListView(ViewGroup viewRoot) {
    listView = new ListView(context);
    LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
    layoutParams.setMargins(dp2px(15), dp2px(5), dp2px(15), dp2px(5));
    listView.setLayoutParams(layoutParams);
    listView.setCacheColorHint(Color.TRANSPARENT);
    listView.setFadingEdgeLength(0);
    listView.setVerticalScrollBarEnabled(false);
    listView.setSelector(new ColorDrawable(Color.TRANSPARENT));
    listView.setDivider(new ColorDrawable(Color.LTGRAY));
    listView.setDividerHeight(dp2px(0.8f));
    if (dialogAdapter == null) {
        dialogAdapter = new ListDialogAdapter();
    }
    listView.setAdapter(dialogAdapter);
    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            dismiss();
            if (listener != null) {
                listener.click(false, position);
            }
        }
    });

    listView.setLayoutAnimation(getLayoutAnimation());
    viewRoot.addView(listView);
}
 
Example 11
Source File: SettingsFragment.java    From HaoReader with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    View rootView = getView();
    if (rootView != null) {
        ListView listView = rootView.findViewById(android.R.id.list);
        if (listView != null) {
            listView.setOverScrollMode(View.OVER_SCROLL_IF_CONTENT_SCROLLS);
            listView.setVerticalScrollBarEnabled(false);
            listView.setDivider(null);
            listView.setDividerHeight(0);
        }
    }
}
 
Example 12
Source File: PhotoAlbumPickerActivity.java    From KrGallery with GNU General Public License v2.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public View createView(Context context) {
    actionBar.setBackgroundColor(Theme.ACTION_BAR_MEDIA_PICKER_COLOR);
    actionBar.setItemsBackgroundColor(Theme.ACTION_BAR_PICKER_SELECTOR_COLOR);
    // actionBar.setBackButtonImage(R.drawable.ic_ab_back);
    actionBar.setBackText(context.getString(R.string.Cancel));
    actionBar.setActionBarMenuOnItemClick(new ActionBar.ActionBarMenuOnItemClick() {
        @Override
        public void onItemClick(int id) {
            if (id == -1) {
                finishFragment();
            } else if (id == 1) {
                if (delegate != null) {
                    finishFragment(false);
                    delegate.startPhotoSelectActivity();
                }
            } else if (id == item_photos) {
                refreshShowPic();//刷新照片目录
            } else if (id == item_video) {
                refreshShowVedio();//刷新录像目录
            }
        }
    });


    fragmentView = new FrameLayout(context);

    FrameLayout frameLayout = (FrameLayout) fragmentView;
    frameLayout.setBackgroundColor(DarkTheme ? 0xff000000 : 0xffffffff);
    //==============videos pick====================
    int res = !singlePhoto && filterMimeTypes.length > 0 ? R.string.PickerVideo : R.string.Album;
    actionBar.setTitle(context.getString(res));
    selectedMode = filterMimeTypes.length > 0 ? 1 : selectedMode;
    listView = new ListView(context);
    listView.setPadding(AndroidUtilities.dp(4), 0, AndroidUtilities.dp(4),
            AndroidUtilities.dp(4));
    listView.setClipToPadding(false);
    listView.setHorizontalScrollBarEnabled(false);
    listView.setVerticalScrollBarEnabled(false);
    listView.setSelector(new ColorDrawable(0));
    listView.setDividerHeight(0);
    listView.setDivider(null);
    listView.setDrawingCacheEnabled(false);
    listView.setScrollingCacheEnabled(false);
    frameLayout.addView(listView);
    FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) listView
            .getLayoutParams();
    layoutParams.width = LayoutHelper.MATCH_PARENT;
    layoutParams.height = LayoutHelper.MATCH_PARENT;
    // layoutParams.bottomMargin = AndroidUtilities.dp(48);
    listView.setLayoutParams(layoutParams);
    listView.setAdapter(listAdapter = new ListAdapter(context));
    AndroidUtilities.setListViewEdgeEffectColor(listView, 0xff333333);

    emptyView = new TextView(context);
    emptyView.setTextColor(0xff808080);
    emptyView.setTextSize(20);
    emptyView.setGravity(Gravity.CENTER);
    emptyView.setVisibility(View.GONE);
    emptyView.setText(R.string.NoPhotos);
    frameLayout.addView(emptyView);
    layoutParams = (FrameLayout.LayoutParams) emptyView.getLayoutParams();
    layoutParams.width = LayoutHelper.MATCH_PARENT;
    layoutParams.height = LayoutHelper.MATCH_PARENT;
    layoutParams.bottomMargin = AndroidUtilities.dp(48);
    emptyView.setLayoutParams(layoutParams);
    emptyView.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            return true;
        }
    });

    progressView = new FrameLayout(context);
    progressView.setVisibility(View.GONE);
    frameLayout.addView(progressView);
    layoutParams = (FrameLayout.LayoutParams) progressView.getLayoutParams();
    layoutParams.width = LayoutHelper.MATCH_PARENT;
    layoutParams.height = LayoutHelper.MATCH_PARENT;
    layoutParams.bottomMargin = AndroidUtilities.dp(48);
    progressView.setLayoutParams(layoutParams);

    ProgressBar progressBar = new ProgressBar(context);
    progressView.addView(progressBar);
    layoutParams = (FrameLayout.LayoutParams) progressView.getLayoutParams();
    layoutParams.width = LayoutHelper.WRAP_CONTENT;
    layoutParams.height = LayoutHelper.WRAP_CONTENT;
    layoutParams.gravity = Gravity.CENTER;
    progressView.setLayoutParams(layoutParams);


    if (loading && (albumsSorted == null || albumsSorted != null && albumsSorted.isEmpty())) {
        progressView.setVisibility(View.VISIBLE);
        listView.setEmptyView(null);
    } else {
        progressView.setVisibility(View.GONE);
        listView.setEmptyView(emptyView);
    }
    return fragmentView;
}
 
Example 13
Source File: AccountFiltersListFragment.java    From CSipSimple with GNU General Public License v3.0 4 votes vote down vote up
@Override 
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    ListView lv = getListView();

    //getListView().setSelector(R.drawable.transparent);
    lv.setCacheColorHint(Color.TRANSPARENT);
    
    
    // View management
    View detailsFrame = getActivity().findViewById(R.id.details);
    dualPane = detailsFrame != null && detailsFrame.getVisibility() == View.VISIBLE;
    

    if (savedInstanceState != null) {
        // Restore last state for checked position.
        curCheckFilterId = savedInstanceState.getLong(CURRENT_CHOICE, SipProfile.INVALID_ID);
        //curCheckWizard = savedInstanceState.getString(CURRENT_WIZARD);
    }
    setListShown(false);
    if(mAdapter == null) {
        if(mHeaderView != null) {
            lv.addHeaderView(mHeaderView , null, true);
        }
        mAdapter = new AccountFiltersListAdapter(getActivity(), null);
        //getListView().setEmptyView(getActivity().findViewById(R.id.progress_container));
        //getActivity().findViewById(android.R.id.empty).setVisibility(View.GONE);
        setListAdapter(mAdapter);
        registerForContextMenu(lv);

        
        lv.setVerticalFadingEdgeEnabled(true);
    }
    
    if (dualPane) {
        // In dual-pane mode, the list view highlights the selected item.
    	Log.d("lp", "dual pane mode");
        lv.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
    	//lv.setVerticalScrollbarPosition(View.SCROLLBAR_POSITION_LEFT);
        lv.setVerticalScrollBarEnabled(false);
        lv.setFadingEdgeLength(50);
        
        updateCheckedItem();
        // Make sure our UI is in the correct state.
        //showDetails(curCheckPosition, curCheckWizard);
    }else {
    	//getListView().setVerticalScrollbarPosition(View.SCROLLBAR_POSITION_RIGHT);
    	lv.setVerticalScrollBarEnabled(true);
    	lv.setFadingEdgeLength(100);
    }
}
 
Example 14
Source File: AccountsEditListFragment.java    From CSipSimple with GNU General Public License v3.0 4 votes vote down vote up
@Override 
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    ListView lv = getListView();

    //getListView().setSelector(R.drawable.transparent);
    lv.setCacheColorHint(Color.TRANSPARENT);
    
    
    // View management
    View detailsFrame = getActivity().findViewById(R.id.details);
    dualPane = detailsFrame != null && detailsFrame.getVisibility() == View.VISIBLE;
    

    if (savedInstanceState != null) {
        // Restore last state for checked position.
        curCheckPosition = savedInstanceState.getLong(CURRENT_CHOICE, SipProfile.INVALID_ID);
        //curCheckWizard = savedInstanceState.getString(CURRENT_WIZARD);
    }
    setListShown(false);
    if(mAdapter == null) {
        if(mHeaderView != null) {
            lv.addHeaderView(mHeaderView , null, true);
        }
        mAdapter = new AccountsEditListAdapter(getActivity(), null);
        mAdapter.setOnCheckedRowListener(this);
        //getListView().setEmptyView(getActivity().findViewById(R.id.progress_container));
        //getActivity().findViewById(android.R.id.empty).setVisibility(View.GONE);
        setListAdapter(mAdapter);
        registerForContextMenu(lv);

        // Prepare the loader.  Either re-connect with an existing one,
        // or start a new one.
        getLoaderManager().initLoader(0, null, this);
        
        lv.setVerticalFadingEdgeEnabled(true);
    }
    
    if (dualPane) {
        // In dual-pane mode, the list view highlights the selected item.
    	Log.d("lp", "dual pane mode");
        lv.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
    	//lv.setVerticalScrollbarPosition(View.SCROLLBAR_POSITION_LEFT);
        lv.setVerticalScrollBarEnabled(false);
        lv.setFadingEdgeLength(50);
        
        updateCheckedItem();
        // Make sure our UI is in the correct state.
        //showDetails(curCheckPosition, curCheckWizard);
    }else {
    	//getListView().setVerticalScrollbarPosition(View.SCROLLBAR_POSITION_RIGHT);
    	lv.setVerticalScrollBarEnabled(true);
    	lv.setFadingEdgeLength(100);
    }
}
 
Example 15
Source File: ActionSheetDialog.java    From RecordVideo with Apache License 2.0 4 votes vote down vote up
@Override
public View onCreateView() {
    LinearLayout ll_container = new LinearLayout(mContext);
    ll_container.setOrientation(LinearLayout.VERTICAL);
    ll_container.setBackgroundColor(Color.TRANSPARENT);

    /** title */
    mTvTitle = new TextView(mContext);
    mTvTitle.setGravity(Gravity.CENTER);
    mTvTitle.setPadding(dp2px(10), dp2px(5), dp2px(10), dp2px(5));

    LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    params.topMargin = dp2px(20);

    ll_container.addView(mTvTitle, params);

    /** title underline */
    mVLineTitle = new View(mContext);
    ll_container.addView(mVLineTitle);

    /** listview */
    mLv = new ListView(mContext);
    mLv.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT, 1));
    mLv.setCacheColorHint(Color.TRANSPARENT);
    mLv.setFadingEdgeLength(0);
    mLv.setVerticalScrollBarEnabled(false);
    mLv.setSelector(new ColorDrawable(Color.TRANSPARENT));

    ll_container.addView(mLv);

    TextView cancelDivider = new TextView(mContext);
    cancelDivider.setGravity(Gravity.CENTER);
    cancelDivider.setBackgroundColor(Color.parseColor("#ffefefef"));
    LayoutParams clp = new LayoutParams(LayoutParams.MATCH_PARENT, 20);
    cancelDivider.setLayoutParams(clp);
    ll_container.addView(cancelDivider);
    /** mCancel btn */
    mTvCancel = new TextView(mContext);
    mTvCancel.setGravity(Gravity.CENTER);
    LayoutParams lp = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    lp.topMargin = dp2px(0);
    lp.bottomMargin = dp2px(0);
    mTvCancel.setLayoutParams(lp);

    ll_container.addView(mTvCancel);

    return ll_container;
}
 
Example 16
Source File: IndexableStickyListView.java    From SprintNBA with Apache License 2.0 4 votes vote down vote up
private void init(Context context, AttributeSet attrs) {
    mContext = context;

    if (attrs != null) {
        TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.IndexableStickyListView);
        mBarTextColor = a.getColor(R.styleable.IndexableStickyListView_indexBar_textColor, getResources().getColor(R.color.default_indexBar_textcolor));
        mBarTextSize = a.getDimension(R.styleable.IndexableStickyListView_indexBar_textSize, getResources().getDimension(R.dimen.default_indexBar_textSize));
        mBarSelectedTextColor = a.getColor(R.styleable.IndexableStickyListView_indexBar_selected_textColor, getResources().getColor(R.color.dafault_indexBar_selected_textColor));
        mRightOverlayColor = a.getColor(R.styleable.IndexableStickyListView_indexListView_rightOverlayColor, getResources().getColor(R.color.default_indexListView_rightOverlayColor));
        mTypeOverlay = a.getInt(R.styleable.IndexableStickyListView_indexListView_type_overlay, 0);
        a.recycle();
    }


    if (mContext instanceof Activity) {
        ((Activity) mContext).getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
    }

    mListView = new ListView(context);
    mListView.setVerticalScrollBarEnabled(false);
    mListView.setOverScrollMode(View.OVER_SCROLL_NEVER);
    mListView.setDivider(null);
    addView(mListView, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));

    mIndexBar = new IndexBar(context, mBarTextColor, mBarSelectedTextColor, mBarTextSize);
    LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
    params.gravity = Gravity.RIGHT;
    params.topMargin = IndexBar.dp2px(context, 16);
    params.bottomMargin = params.topMargin;
    addView(mIndexBar, params);
    if (mTypeOverlay == 1) {
        showCenterOverlayView(true);
    } else if (mTypeOverlay == 2) {
        showRightOverlayView(true, mRightOverlayColor);
    }

    mSearchLayout = new SearchLayout(context);
    LayoutParams paramsLayout = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
    addView(mSearchLayout, paramsLayout);
    mSearchLayout.setVisibility(GONE);

    mListView.setOnItemClickListener(this);
    mListView.setOnScrollListener(this);

    mIndexBar.setOnIndexSelectedListener(new IndexBar.OnIndexTitleSelectedListener() {
        @Override
        public void onSelection(int position, String indexTitle) {
            if (mStickView != null) {
                if (!mStickView.getText().toString().equals(indexTitle)) {
                    mStickView.setText(indexTitle);
                }
                if (mStickView.getY() != 0) {
                    mStickView.setY(0);
                }
            }
        }
    });
}
 
Example 17
Source File: ActionSheetDialog.java    From SprintNBA with Apache License 2.0 4 votes vote down vote up
@Override
public View onCreateView() {
    LinearLayout ll_container = new LinearLayout(mContext);
    ll_container.setOrientation(LinearLayout.VERTICAL);
    ll_container.setBackgroundColor(Color.TRANSPARENT);

    /** title */
    mTvTitle = new TextView(mContext);
    mTvTitle.setGravity(Gravity.CENTER);
    mTvTitle.setPadding(dp2px(10), dp2px(5), dp2px(10), dp2px(5));

    LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    params.topMargin = dp2px(20);

    ll_container.addView(mTvTitle, params);

    /** title underline */
    mVLineTitle = new View(mContext);
    ll_container.addView(mVLineTitle);

    /** listview */
    mLv = new ListView(mContext);
    mLv.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT, 1));
    mLv.setCacheColorHint(Color.TRANSPARENT);
    mLv.setFadingEdgeLength(0);
    mLv.setVerticalScrollBarEnabled(false);
    mLv.setSelector(new ColorDrawable(Color.TRANSPARENT));

    ll_container.addView(mLv);

    /** mCancel btn */
    mTvCancel = new TextView(mContext);
    mTvCancel.setGravity(Gravity.CENTER);
    LayoutParams lp = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    lp.topMargin = dp2px(7);
    lp.bottomMargin = dp2px(7);
    mTvCancel.setLayoutParams(lp);

    ll_container.addView(mTvCancel);

    return ll_container;
}
 
Example 18
Source File: ActionSheetDialog.java    From FlycoDialog_Master with MIT License 4 votes vote down vote up
@Override
public View onCreateView() {
    LinearLayout ll_container = new LinearLayout(mContext);
    ll_container.setOrientation(LinearLayout.VERTICAL);
    ll_container.setBackgroundColor(Color.TRANSPARENT);

    /** title */
    mTvTitle = new TextView(mContext);
    mTvTitle.setGravity(Gravity.CENTER);
    mTvTitle.setPadding(dp2px(10), dp2px(5), dp2px(10), dp2px(5));

    LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    params.topMargin = dp2px(20);

    ll_container.addView(mTvTitle, params);

    /** title underline */
    mVLineTitle = new View(mContext);
    ll_container.addView(mVLineTitle);

    /** listview */
    mLv = new ListView(mContext);
    mLv.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT, 1));
    mLv.setCacheColorHint(Color.TRANSPARENT);
    mLv.setFadingEdgeLength(0);
    mLv.setVerticalScrollBarEnabled(false);
    mLv.setSelector(new ColorDrawable(Color.TRANSPARENT));

    ll_container.addView(mLv);

    /** mCancel btn */
    mTvCancel = new TextView(mContext);
    mTvCancel.setGravity(Gravity.CENTER);
    LayoutParams lp = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    lp.topMargin = dp2px(7);
    lp.bottomMargin = dp2px(7);
    mTvCancel.setLayoutParams(lp);

    ll_container.addView(mTvCancel);

    return ll_container;
}
 
Example 19
Source File: PopupWindowList.java    From WechatPopupWindow with Apache License 2.0 4 votes vote down vote up
public void show() {
    if (mAnchorView == null) {
        throw new IllegalArgumentException("PopupWindow show location view can  not be null");
    }
    if (mItemData == null) {
        throw new IllegalArgumentException("please fill ListView Data");
    }
    mPopView = new ListView(mContext);
    mPopView.setBackgroundColor(ContextCompat.getColor(mContext, android.R.color.white));
    mPopView.setVerticalScrollBarEnabled(false);
    mPopView.setDivider(null);
    mPopView.setAdapter(new ArrayAdapter<>(mContext,
            android.R.layout.simple_list_item_1, mItemData));
    if (mItemClickListener != null) {
        mPopView.setOnItemClickListener(mItemClickListener);
    }
    mPopView.measure(View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED),
            View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED));
    if (mPopupWindowWidth == 0) {
        mPopupWindowWidth = mDeviceWidth / 3;
    }
    if (mPopupWindowHeight == 0) {
        mPopupWindowHeight = mItemData.size() * mPopView.getMeasuredHeight();
        if (mPopupWindowHeight > mDeviceHeight / 2) {
            mPopupWindowHeight = mDeviceHeight / 2;
        }
    }
    mPopupWindow = new PopupWindow(mPopView, mPopupWindowWidth, mPopupWindowHeight);
    if (mPopAnimStyle != 0) {
        mPopupWindow.setAnimationStyle(mPopAnimStyle);
    }
    mPopupWindow.setOutsideTouchable(true);
    mPopupWindow.setFocusable(mModal);
    mPopupWindow.setBackgroundDrawable(new BitmapDrawable(mContext.getResources(), (Bitmap) null));


    Rect location = locateView(mAnchorView);
    if (location != null) {
        int x;
        //view中心点X坐标
        int xMiddle = location.left + mAnchorView.getWidth() / 2;
        if (xMiddle > mDeviceWidth / 2) {
            //在右边
            x = xMiddle - mPopupWindowWidth;
        } else {
            x = xMiddle;
        }
        int y;
        //view中心点Y坐标
        int yMiddle = location.top + mAnchorView.getHeight() / 2;
        if (yMiddle > mDeviceHeight / 2) {
            //在下方
            y = yMiddle - mPopupWindowHeight;
        } else {
            //在上方
            y = yMiddle;
        }
        mPopupWindow.showAtLocation(mAnchorView, Gravity.NO_GRAVITY, x, y);
    }
}
 
Example 20
Source File: MainPageActivity.java    From AndroidFaceRecognizer with MIT License 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.main_page);
	
	
	adView = new AdView(this);
	adView.setAdUnitId("ca-app-pub-4147454460675251/3837655321");
	adView.setAdSize(AdSize.BANNER);
	
	adView.setAdListener(adListener);
	
	RelativeLayout adLayout = (RelativeLayout)findViewById(R.id.main_page_adview_layout);
	adLayout.addView(adView);
	
	RelativeLayout.LayoutParams adViewlp = new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
	adViewlp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
	adViewlp.addRule(RelativeLayout.CENTER_HORIZONTAL);
	adView.setLayoutParams(adViewlp);

	
	AdRequest request = new AdRequest.Builder()
	.addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
    .addTestDevice("04E14595EE84A505616E50A99B15252D")
    .build();
	
	
	adView.loadAd(request);
	
	System.out.println("---------------------- istestdevice: "+request.isTestDevice(this));

	
	mContext = this;
	
	DisplayMetrics dm = new DisplayMetrics();
	getWindowManager().getDefaultDisplay().getMetrics( dm );
	
	screenWidth = dm.widthPixels;
	screenHeight = dm.heightPixels;
	
	final TextView headerText = (TextView)findViewById(R.id.mainHeaderText);
	RelativeLayout.LayoutParams headerTextParams = (RelativeLayout.LayoutParams)headerText.getLayoutParams();
	headerTextParams.leftMargin = screenHeight/8;
	headerText.setLayoutParams(headerTextParams);
	headerText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, (float)screenHeight/35);
	headerText.setText("Face Recognition");
	headerText.setTextColor(Color.LTGRAY);
	headerText.setGravity(Gravity.LEFT | Gravity.CENTER_VERTICAL);
	headerText.setTypeface(null, Typeface.BOLD);
	
	ImageView headerIcon = (ImageView)findViewById(R.id.mainHeaderIcon);
	RelativeLayout.LayoutParams iconLParams = new RelativeLayout.LayoutParams(screenHeight/11, screenHeight/11);
	iconLParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT | RelativeLayout.CENTER_VERTICAL);
	iconLParams.leftMargin = screenHeight/80;
	headerIcon.setLayoutParams(iconLParams);
	
	
	ListView listView = (ListView)findViewById(R.id.mainListView);
	ListAdapter listAdapter = new ListAdapter();
	listView.setAdapter(listAdapter);
	listView.setOnItemClickListener(itemClickListener);
	
	RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams)listView.getLayoutParams();
	params.leftMargin = screenWidth/10;
	params.rightMargin = screenWidth/10;
	params.topMargin = screenHeight/12;
	listView.setLayoutParams(params);
	listView.setVerticalScrollBarEnabled(false);

}