Open bing086 opened 7 years ago
@bing086 same issue. i cant hide it either.
@bing086 i found a way to do it. get the sliderlayout as an object
@BindView(R.id.home_slider)
SliderLayout offersSliderLayout;
and then setIndicatorVisibility
offersSliderLayout.setIndicatorVisibility(PagerIndicator.IndicatorVisibility.Invisible);
@UsmanGhauri i tried this but got a null pointer exception..:/ Please help me i want to get rid of that black background.
@heyiamnikhil : are you using butter knife? because i think you're not using butter knife to bindviews. if you don't want to use it either dont worry. first just create a reference for it like this
SliderLayout offersSliderLayout = (SliderLayout) findViewById(R.id.home_slider);
and when you're setting your slider thingsup, call
offersSliderLayout.setIndicatorVisibility(PagerIndicator.IndicatorVisibility.Invisible);
@UsmanGhauri i tried this but this only removed the page indicators not the black background..Black background is still showing along with the image..i want to remove the black background not the page indicators.
This is my slider in my xml file:
<com.daimajia.slider.library.SliderLayout android:id="@+id/slider" android:layout_width="match_parent" custom:pager_animation="Accordion" custom:auto_cycle="true" custom:indicator_visibility="visible" custom:pager_animation_span="1100" android:layout_height="200dp"/>
This is the code i am using for this slider:
mDemoSlider = (SliderLayout) findViewById(R.id.slider);
HashMap<String, String> url_maps = new HashMap<String, String>();
url_maps.put("Save Some Money", "http://www.apphics.com/GD/images/5.jpg");
url_maps.put("Get Quality Education", "http://www.apphics.com/GD/images/contact.jpg");
url_maps.put("", "http://www.apphics.com/GD/images/institute.jpg");
url_maps.put("", "http://www.apphics.com/GD/images/building1.jpg");
for (String name : url_maps.keySet()) {
TextSliderView textSliderView = new TextSliderView(this);
// initialize a SliderLayout
textSliderView
.image(url_maps.get(name))
.setScaleType(BaseSliderView.ScaleType.Fit)
.setOnSliderClickListener(this);
mDemoSlider.addSlider(textSliderView);
}
mDemoSlider.setPresetTransformer(SliderLayout.Transformer.Default);
mDemoSlider.setPresetIndicator(SliderLayout.PresetIndicators.Center_Bottom);
mDemoSlider.setCustomAnimation(new DescriptionAnimation());
mDemoSlider.setDuration(4000);
mDemoSlider.addOnPageChangeListener(this);
Please tell me what to change and where..:)
@heyiamnikhil can you screenshot and send here which black background you're talking about. this issue was regarding indicator so i assumed you're talking about indicator .
@UsmanGhauri I am talking about the black background which only comes behind the Text.
I want to remove the text so i don't need this background and without the text this background is looking very odd..Please help!
@heyiamnikhil : For that you need to customize a bit.
public class OfferSliderView extends BaseSliderView {
public OfferSliderView(Context context) {
super(context);
}
@Override
public View getView() {
View v = LayoutInflater.from(getContext()).inflate(R.layout.offer_slider_view, null);
ImageView target = (ImageView) v.findViewById(R.id.daimajia_slider_image);
TextView description = (TextView) v.findViewById(R.id.description);
description.setText(getDescription());
bindEventAndShow(v, target);
return v;
}
}
at this point this custom layout "R.layout.offer_slider_view" will be missing that's because you have to make it in your project. create any layout... i did like this
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent">
<ImageView
android:id="@+id/daimajia_slider_image"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/ic_ejazah_placeholder"
android:contentDescription="@string/app_name" />
<ProgressBar
android:id="@+id/loading_bar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true" />
<LinearLayout
android:id="@+id/description_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="@drawable/offer_slider_gradient"
android:gravity="center_vertical"
android:minHeight="30dp"
android:orientation="vertical"
android:padding="10dp">
<TextView
android:id="@+id/description"
fontPath="fonts/Roboto_Light.ttf"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:shadowColor="@android:color/black"
android:shadowDx="1"
android:shadowDy="2"
android:shadowRadius="1"
android:textColor="@android:color/white"
android:textSize="12sp" />
</LinearLayout>
that 'description_layout' is responsible to show description of text so go ahead and remove / add anything there. if you want the black label background behind the description text to be removed or transparent, set its android:background="@drawable/offer_slider_gradient" to transparent.
you can even remove / set transparency to text color. upto your imaginations now :)
不能隐藏Indicator的底部背景吗, 始终会显示出来