dexafree / MaterialList

An Android library aimed to get the beautiful CardViews that Google shows at its official design specifications
1.61k stars 377 forks source link

BasicButtonsCard title not appearing #91

Open dhruvilbadani opened 9 years ago

dhruvilbadani commented 9 years ago

I am using BigImageButtonsCards and BasicButtonsCards in my MaterialListView. For some reason, the titles of the the BasicButtonsCards do not appear even though the text colour is black and the card background colour is white. However, when I use BasicButtonsCards only (no BigImageButtonsCards), the titles appear. Any idea why?

dexafree commented 9 years ago

I just tried this

 BigImageButtonsCard bibc = new BigImageButtonsCard(this);
 bibc.setTitle("My Title");
 bibc.setLeftButtonText("LEFT");
 bibc.setRightButtonText("RIGHT");
 bibc.setDrawable("http://1.bp.blogspot.com/-AuIFbAvqpGw/URaJXK6dyaI/AAAAAAAAAHg/nBxxESy1AuM/s1600/tux.png");
 bibc.setDescription("My description");
 bibc.setTitleColor(Color.parseColor("#FF0000"));

 BasicButtonsCard bbc = new BasicButtonsCard(this);
 bbc.setTitle("My other title");
 bbc.setLeftButtonText("LEFT");
 bbc.setRightButtonText("RIGHT");
 bbc.setDrawable("http://1.bp.blogspot.com/-AuIFbAvqpGw/URaJXK6dyaI/AAAAAAAAAHg/nBxxESy1AuM/s1600/tux.png");
 bbc.setDescription("My other description");

 mListView.add(bibc);
 mListView.add(bbc);

It worked as expected

http://i.imgur.com/2CvGgq4.jpg

Which MaterialList version and Android Version are you using?

dhruvilbadani commented 9 years ago

Fixed, thank you. Another question though. I am using a Big Image with Buttons card. I'm using the setDrawable(String) method to set the image. How do I make this image fit the width of the card?

dexafree commented 9 years ago

I'll take a look at it, as now I don't know if the code calls the fit methods from Picasso

dexafree commented 9 years ago

It should be solved with v2.4.6 https://github.com/dexafree/MaterialList/commit/258232d7362d49545a5f686e912c73dd62f35020

dhruvilbadani commented 9 years ago

Solved as in? I don't need to do anything more than setDrawable() with my URL?

dhruvilbadani commented 9 years ago

Okay so I used 2.4.6. The images are centered but they yet do not fit the width of the card. Any help would be awesome

dexafree commented 9 years ago

I think I will need to provide some "Image Behaviour" methods in order to satisfy all the needs (maybe some users prefer centered images even though the don'y fit the entire width).

I will try to take a look at it.

dexafree commented 9 years ago

Try the new 2.5.0 https://github.com/dexafree/MaterialList/commit/c101bc01ccfb50a5cf26c2891fdad86213ba1987

You can now set the ScaleType directly to the Card

dhruvilbadani commented 9 years ago

Thanks for that. I tried all the ScaleTypes but to no avail. Am I missing something here?

dexafree commented 9 years ago

Can you provide an example card in order to try it?

dhruvilbadani commented 9 years ago

String useURL = "http://assets.sbnation.com/assets/1035916/crazy-car-accident.jpeg"; BigImageButtonsCard card = new BigImageButtonsCard(getApplicationContext()); card.setDrawable(useURL); card.setImageScaleType(ImageView.ScaleType.CENTER); // Tried the scale types CENTER, CENTER_CROP, CENTER_INSIDE, FIT_CENTER, FIT_END, FIT_START, FIT_XY and MATRIX at this line card.setDescription(cardDescription); card.setDescriptionColor(Color.BLACK); card.setLeftButtonText(leftText); card.setLeffButtonTextColor(Color.BLACK); card.setRightButtonText(rightText); card.setRightButtonTextColor(Color.BLACK); mlv.add(card);

dexafree commented 9 years ago

Sorry, I forgot to change one line at the XML that made this not work.

Now we're discussing about the new library version, which will bring a new nice Card building system, so I won't change the code base now, but if you don't mind downloading the library and importing it as a module, I can tell you which line you need to change in order for it to work.

(You only have to git clone the project, import the 'materialList' module to your project, and add the

compile project(':materialList')

line to your app build.gradle. You can see how it's done on the sample app).

The line is at the materialList/src/main/res/layout/material_image_with_buttons_card.xml file, and you need to change at line 19, from android:layout_width="wrap_content" to android:layout_width="fill_parent".

And it will work as expected.

dhruvilbadani commented 9 years ago

It's a basic question but how do I import the 'materialList' module to my project? I have git cloned the project into my project's folder.

dexafree commented 9 years ago
  1. Open your project
  2. File -> Import module
  3. Go to the MaterialList folder
  4. Select the materialList module
  5. Check in your project that it has been added to the settings.gradle file
  6. In your app's module build.gradle, add
compile project(':materialList')

Check the MaterialList sample app in order to se how the build.gradle files should be

dhruvilbadani commented 9 years ago

Yes exactly, but I can't find the import module option in File in Android Studio. I went into the project Structure option and tried adding, but failed.

dexafree commented 9 years ago

File -> New -> Import module