We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I want to center the child in horizontalListview but horizontal listview not taking wrap_content from xml. any suggestions?
The text was updated successfully, but these errors were encountered:
The code is Same what it has in horizontalList. Problem here is Horizontal list has no effect on wrap_content as it takes match parent
On Tue, May 13, 2014 at 11:10 PM, Troy Locke [email protected]:
Could you send some sample code. Or post your layout here. — Reply to this email directly or view it on GitHubhttps://github.com//issues/43#issuecomment-42985540 .
Could you send some sample code. Or post your layout here.
— Reply to this email directly or view it on GitHubhttps://github.com//issues/43#issuecomment-42985540 .
Sorry, something went wrong.
Managed to make it work, now the content width is set to wrap_content and you can give gravity to your parent layout.
Add this function to the component class file. public void resetPosition() {
if (mContext != null && mAdapter != null) { DisplayMetrics metrics = mContext.getResources() .getDisplayMetrics(); int width = metrics.widthPixels; if (mAdapter.getCount() * mChildWidth > 0 && mAdapter.getCount() * mChildWidth < width) { Log.e("child width", "child: " + mAdapter.getCount() + ": width:" + mChildWidth + ""); setLayoutParams(new LinearLayout.LayoutParams( mAdapter.getCount() * mChildWidth, 300)); } }
} After you set the adapter/notifydatasetchanged
call the function like
yourHorizontalListView.post(new Runnable() {
@Override public void run() { // TODO Auto-generated method stub yourHorizontalListView.resetPosition(); } });
Worked in my case.
No branches or pull requests
I want to center the child in horizontalListview but horizontal listview not taking wrap_content from xml. any suggestions?
The text was updated successfully, but these errors were encountered: