Repository navigation
Shadow behind AutoFitTextView #31
Description
Activity
I thought this is already handled.
As a workaround, you might be able to put it inside a container view (FrameLayout, for example), and add the padding there, and set "clipChildren" to false on the it. Maybe it will work for now.
Thanks! I will give this a try:)
Did it help?
odd. thank you for trying to fix it.
Perhaps rolling your own layout class may help... a base example for understanding forces the layout to be square. Perhaps you can rework the example to get your desired effect.
/* * Copyright (C) 2014 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.example.android.activityscenetransitionbasic; import android.content.Context; import android.util.AttributeSet; import android.widget.FrameLayout; /** * {@link android.widget.FrameLayout} which forces itself to be laid out as square. */ public class SquareFrameLayout extends FrameLayout { public SquareFrameLayout(Context context) { super(context); } public SquareFrameLayout(Context context, AttributeSet attrs) { super(context, attrs); } public SquareFrameLayout(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); } public SquareFrameLayout(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { super(context, attrs, defStyleAttr, defStyleRes); } @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { final int widthSize = MeasureSpec.getSize(widthMeasureSpec); final int heightSize = MeasureSpec.getSize(heightMeasureSpec); if (widthSize == 0 && heightSize == 0) { // If there are no constraints on size, let FrameLayout measure super.onMeasure(widthMeasureSpec, heightMeasureSpec); // Now use the smallest of the measured dimensions for both dimensions final int minSize = Math.min(getMeasuredWidth(), getMeasuredHeight()); setMeasuredDimension(minSize, minSize); return; } final int size; if (widthSize == 0 || heightSize == 0) { // If one of the dimensions has no restriction on size, set both dimensions to be the // on that does size = Math.max(widthSize, heightSize); } else { // Both dimensions have restrictions on size, set both dimensions to be the // smallest of the two size = Math.min(widthSize, heightSize); } final int newMeasureSpec = MeasureSpec.makeMeasureSpec(size, MeasureSpec.EXACTLY); super.onMeasure(newMeasureSpec, newMeasureSpec); } }I don't see why this solution should help, but you are free to try.
On Wed, May 25, 2016 at 12:36 AM, William Crandell <notifications@github.com
wrote:
Perhaps rolling your own layout class may help... a base example for
understanding forces the layout to be square. Perhaps you can rework the
example to get your desired effect./*
- Copyright (C) 2014 The Android Open Source Project
* - Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
* -
http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
*/
package com.example.android.activityscenetransitionbasic;
import android.content.Context;
import android.util.AttributeSet;
import android.widget.FrameLayout;/**
-
{@link android.widget.FrameLayout} which forces itself to be laid out as square.
*/
public class SquareFrameLayout extends FrameLayout {public SquareFrameLayout(Context context) {
super(context);
}public SquareFrameLayout(Context context, AttributeSet attrs) {
super(context, attrs);
}public SquareFrameLayout(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}public SquareFrameLayout(Context context, AttributeSet attrs,
int defStyleAttr, int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
}@OverRide
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
final int widthSize = MeasureSpec.getSize(widthMeasureSpec);
final int heightSize = MeasureSpec.getSize(heightMeasureSpec);if (widthSize == 0 && heightSize == 0) { // If there are no constraints on size, let FrameLayout measure super.onMeasure(widthMeasureSpec, heightMeasureSpec); // Now use the smallest of the measured dimensions for both dimensions final int minSize = Math.min(getMeasuredWidth(), getMeasuredHeight()); setMeasuredDimension(minSize, minSize); return; } final int size; if (widthSize == 0 || heightSize == 0) { // If one of the dimensions has no restriction on size, set both dimensions to be the // on that does size = Math.max(widthSize, heightSize); } else { // Both dimensions have restrictions on size, set both dimensions to be the // smallest of the two size = Math.min(widthSize, heightSize); } final int newMeasureSpec = MeasureSpec.makeMeasureSpec(size, MeasureSpec.EXACTLY); super.onMeasure(newMeasureSpec, newMeasureSpec);}
}
—
You are receiving this because you commented.
Reply to this email directly or view it on GitHub
#31 (comment)- Copyright (C) 2014 The Android Open Source Project
as stated
put it inside a container view (FrameLayout, for example)
--@AndroidDeveloperLBthe example I posted shows how to force dimensions which may or may not be useful...hard to say without seeing how @axelfran is trying to get it done...so the example I provide maybe somewhat unrelated idk

Hi,
I need to add a shadow behind the textview. The shadow has a quite large radius, so that it with my current solution will be clipped in many instances as the bounding box isn't increased when I add the shadow.
If this was a normal TextView I could just add some padding to it to avoid the clipping, however when I do that now the text becomes smaller. I would like to avoid that.
Anyone have any thoughts on how I should add padding without making the text smaller?
Thanks in advance!